You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to dispatch a click event on a button -
(defnenter-to-click"It captures the enter event on the given element selector (s1) and triggers a click event on the element selector (s2)"
[s1 s2]
(let [el1 (sel s1) el2 (sel s2)]
(listen! el1 :keydown (fn [ev]
(when (= (:keyCode ev) 13)
(dispatch! (sel"#sign_in") "click" {}))))))
The listen! event works, I am even able to log messages from the when block , however the dispatch doesnt work. I am however able to trigger a click event using jquery from the browsers console.
Any help will be appreciated.
Thanks,
Murtaza
The text was updated successfully, but these errors were encountered:
I know this is an old issue, so this comment is for the benefit of anyone else with the same question. As far as I can tell Google Closure Library does not provide a method for dispatching native browser events. There may be a better way, but here is the code I am using, at the moment to trigger a browser click event.
(defnclick-event []
(or (try (js/MouseEvent."click" #js {:view js/window :bubblestrue:cancelabletrue})
(catch:default _))
;; NOTE: Fallback for Safari 5 in which `MouseEvent` is defined but broken.
(doto (.createEvent js/document "MouseEvent")
(.initEvent"click"truetrue))))
(defnclick [node]
(if-not (fn? (.-click node))
(.dispatchEvent node (click-event))
(.click node)))
It should be possible to make this code generic enough to dispatch other browser events, but I have not had the need or the time to do so. If domina's dispatch! function is intended to support native browser events, I would be happy to take a stab at fixing it.
Hi,
I am trying to dispatch a click event on a button -
The listen! event works, I am even able to log messages from the when block , however the dispatch doesnt work. I am however able to trigger a click event using jquery from the browsers console.
Any help will be appreciated.
Thanks,
Murtaza
The text was updated successfully, but these errors were encountered: