How to simulate a "click" event in Haskell

211 views Asked by At

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.

1

There are 1 answers

0
snak On BEST ANSWER

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