When you return false
from within a jQuery
event handler, the library will automatically call e.preventDefault
and e.stopPropagation
(for more info see here). Calling this functions is the right way to control the behaviour of the event
.
Domina wraps js/Event
in something that ClojureScript
understands. So you can call preventDefault
and stopPropagation
directly, without using the Javascript interop. You can read more about this neat trick here: https://github.com/levand/domina#event-objects.
This trick is probably what is causing returning false
to not work at all. The way this trick is implemented (take a look at the code here) is by wrapping your function with another function that always return true
.
So your code should be more like this:
(listen! (by-id "my-form") :submit
(fn [e]
(do
(log "submit suppressed")
(prevent-default e)
(stop-propagation e))))