I have the string with html markup, an I want to cretae Doc elment from it like this:
Doc.FromHtm "<div><p>.....</p>.....</div>"
As I understand that this is not possible right now. Ok, what is not possible to accurately sew, I tried to roughly nail using jquery:
JQuery.JQuery.Of( "." + class'name ).First().Html(html'content)
But to call this code, I need to specify an event handler for the Doc element. But it is not implemented in UI.Next. I tried to track changes of a model with a given CSS class asynchronously:
let inbox'post'after'render = MailboxProcessor.Start(fun agent ->
let rec loop (ids'contents : Map<int,string>) : Async<unit> = async {
// try to recive event with new portion of data
let! new'ids'contents = agent.TryReceive 100
// calculate the state of the agent
let ids'contents =
// merge Map's
( match new'ids'contents with
| None -> ids'contents
| Some (new'ids'contents) ->
new'ids'contents @ (Map.toList ids'contents)
|> Map.ofList )
|> Map.filter( fun id content ->
// calculate CSS class name
let class'name = post'text'view'class'name id
// change it's contents of html
JQuery.JQuery.Of( "." + class'name ).First().Html(content).Size() = 0)
// accept the state of the agent
return! loop ids'contents }
loop Map.empty )
and then, for example for one element:
inbox'post'after'render.Post [id, content]
But it is too difficult, unreliable and not really working. Please give me an idea how to solve the problem if possible. Thanks in advance!
Just in case someone needs to use static HTML in WebSharper on the server (I needed to add some javascript to the WebSharper generated HTML page), there is fairly new
Doc.Verbatim
usable e.g. like