I’ve got a click event not firing on iOS on click $('html, body')
so want to implement touchstart
as well. I don’t want the event firing twice though. Is there anyway to do something like $element.on('click|touchstart')
where it tries click
first and if it doesn’t fire does touchstart
instead?
define both events separately and inside the handler, kill the event.
Thanks. By “kill”, do you mean off()? So if click fires kill touchstart and vice versa via event.type
I think he means .preventDefault();?
That would still fire twice I think.
Event Bubbling?
It’s more to do with the binding itself rather than bubble. I assume if there are two events bound to the same element preventing propagation wouldn’t accomplish anything.
I think, if I understand @Dormilich correctly, a simple elegant solution is there. Add both events and when it first fires remove one that didn’t fire.
1 Like
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.