I’m trying my hand a writing a clojureScript One project, but I’m having trouble removing an event listener (unlisten) – listener is registered with this code:
(defn- add-expand_fold-listener
"Accepts a ele-id and creates listeners for click events on div
which will then fire rendering changes"
[ele-id]
(log/log "adding opening listeners")
(event/listen (single-node (by-id ele-id))
"click"
#(dispatch/fire (re-class ele-id "foldup" "expand"))))
But when I try to unlisten with this code:
(defn- remove-expand_fold-listener
"Accepts a ele-id and removes listener for click events on div"
[ele-id]
(log/log "removing opening listener")
(event/unlisten (by-id ele-id)
"click"
#(dispatch/fire (re-class ele-id "foldup" "expand"))
false)
(log/log "done removing listener"))
The code runs with no errors but the listener is not removed, I guess I have a syntax error, but I’m not sure where.
Any help would be greatly appreciated.
Thanks Larry
Solved: Instead of trying to use domina (which is good stuff but not all of the functions are in the lein-deps) and trying to use the clojureScript One event model finally just went right to the source… added to the require section of the namespace:
Then in the remove function used:
And it works like a champ.
Hope this helps someone in the future…