cbDoc という名前の表現用に、リアクティブな Var 変数 varDone と Doc.Checkbox があります。varDone の値を変更した後、関数を呼び出す必要があります。このために、次の疑似コードに示すコードを作成しました。
open WebSharper
open WebSharper.UI.Next
open WebSharper.UI.Next.Html
open WebSharper.UI.Next.Notation
// declaring reactive bool variable
let varDone = Var.Create false
(* something else *)
// creting Doc-representation of my model
let renderModel model =
// declaring its representation Doc element
let cbDone = Div0 [ Doc.CheckBox [ "type" ==> "checkbox" ] varDone ]
let result'doc = // a Doc-representation, that contains cbDone
let my'handler() : unit -> unit = // a function that should be called when changing the value of varDone
// add an event handler for the element cbDone changes
(Doc.AsPagelet cbDone).Body.AddEventListener( "change", my'handler, false )
result'doc
残念ながら、チェックボックスの変更時にイベントは発生しません。問題は、私が間違っているのは何ですか? varDone 変数の値の変化に対応する別の方法はありますか?
UPD
最も悲しいことは、チェックボックスのある要素にはイベント ハンドラーさえないことです。これは、ブラウザでデバッグすると明らかです。