Lyn Headley
Lyn Headley

Reputation: 11588

How to trigger and handle a click event?

In the following code, I try to handle a click event on a checkbox. I expect to see the word "hello" printed in the javascript console, but instead I see nothing. How can I modify the code to get the print statement to execute?

 let checkGroupByRounds = Dom_html.createInput ~_type:(Js.string "checkbox") doc in
  Lwt_js_events.clicks checkGroupByRounds (fun event event_loop ->
    Lwt.return (Printf.printf "hello"));
  Dom.appendChild container checkGroupByRounds;

Upvotes: 0

Views: 210

Answers (1)

hhugo
hhugo

Reputation: 241

You need to flush the standard output with a new line Printf.printf "hello\n" or an explicit flush flush stdout.

Upvotes: 1

Related Questions