Do I understand this correctly: you're using WebSharper.Piglets, and WebSharper.Html elements, in conjunction with UI.Next Vars? It really wasn't designed to be used this way :/ The Piglets implementation for UI.Next is WebSharper.Forms, and more generally it is really recommended to use Vars with Docs, as those are designed to avoid the sink problem below.

In your current situation you could do something like this:

1
2
3
4
5
6
let attrDyn attrName view e =
    view |> View.Sink (fun v -> e.SetAttribute(attrName, v))

// ...

Controls.Input v |>! attrDyn "data-list" var.View

But you have to be careful with View.Sink: if the above is an element you insert a set number of times into your document, then it's all right, but if it's a snippet that gets inserted repeatedly (for example if it's in a Piglet.Many) then you're exposing yourself to memory leaks (which I'll admit is kind of ironic for a Sink...).

By on 2/10/2017 2:02 AM ()

Thanks for the reply, that is clarifying. I've been using Piglets in conjunction with Websharper.Html elements as per https://github.com/intellifactory/websharper.piglets/blob/master/WebSharper.Piglets.Test/App.fs. I didn't know about WebSharper.Forms (or if I did, assumed it was superceded by UI.Next or Formlets). Is there some documentation somewhere about the tradoffs between Piglets + WebSharper.Html and WebSharper.Forms? Should I just prefer the latter? In general I've found the documentation to be quite vague about the relation (in terms of design, interoperability, current best-practices, and legacy-support modules) between the various Websharper modules.

By on 2/10/2017 8:14 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper