javascripthaskelljsdomghcjs

How to simulate a "click" event in Haskell


I want to internally click a button in Haskell, and I'm using (maybe I'm wrong) the function dispatchEvent_ https://hackage.haskell.org/package/jsaddle-dom-0.9.4.1/docs/JSDOM-Generated-EventTarget.html. My code is the following:

event  <- (toJSVal "click" )
dispatchEvent_ (button_run :: HTMLButtonElement) (MouseEvent event  )

However I encounter the following runtime error:

Argument 1 ('event') to EventTarget.dispatchEvent must be an instance of Event.

Thanks for the help.


Solution

  • Use JSDOM.Generated.HTMLElement.click to fire a click event on your HTMLButtonElement.