f# - Writing handlers for JS.Window.Onpopstate in Websharper -


i'm trying proper back-button support in websharper-app. can put stuff in history fine:

type myrecord = { foo: int; bar: string }  js.window.history.pushstate({foo=10; bar="hello"}, "", "mysuffix") 

i hoping add corresponding handler onpopstate doing this:

js.window.onpopstate <- (fun e -> javascript.console.info e.state.bar) 

unfortunately, event has type js.window.onpopstate : dom.event -> unit , dom.event doesn't have field state getting state, though corresponding "real" javascript event does.

how access state stored pushstate in onpopstate handler?

you can access arbitrary fields objects using dynamic operator ?:

js.window.onpopstate <- (fun e ->     console.info e?state.bar ) 

note still need use [<inline>] call arbitrary method.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -