Bolero 0.1.89
Pre-release
Pre-release
Features
#13: Add DOM element reference functions.
-
attr.ref : (ElementRef -> unit) -> Attr
calls the given function with a reference to the element when it is inserted. -
attr.bindRef : ElementRefBinder -> Attr
binds the element when it is inserted. TheElementRefBinder
is typically created as a component field usingElementRefBinder()
and used in event handlers through its.ref
property, of typeElementRef
.
type View() =
inherit ElmishComponent<Model, Message>()
let buttonRef = ElementRefBinder()
override this.View model dispatch =
button [
attr.bindRef buttonRef
on.click (fun _ -> someJsCallback(buttonRef.ref))
] [text "Click me!"]