jeudi 25 juin 2015

The ability to create Doc element of hypertext in Websharper.UI.Next

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!




Aucun commentaire:

Enregistrer un commentaire