Skip to content

Instantly share code, notes, and snippets.

@giuliohome giuliohome/OpenDetails.fs
Last active Jul 30, 2019

What would you like to do?
Create a form to post a request with parameter for a new detail tab and render it into html, all typesafe, from f# to javascript
let (|==>) (param_name, param_id) (safe_url:EndPoint) =
let router = Router.Infer()
let url = router.Link(safe_url)
form [ "_blank"; attr.action url; ("form" + param_id); attr.method "POST" ] [
a [ (fun el ev ->
let frm = JS.Document.GetElementById ("form" + param_id) |> As<HTMLFormElement>
) ] [text param_id]
input [attr.``type`` "hidden"; param_name; attr.value param_id] []
let ToHtml (doc:Doc) : JQuery = // string =
let magic = JS.Document.CreateElement "magic"
doc |> Doc.Run magic
//magic.InnerHTML // event handlers don't stay when taking the HTML string
// Thanks to the guru - Loïc Denuzière - @Tarmil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.