Backbone.js - Both Click And Double Click Event Getting Fired On An Element
Solution 1:
The jQuery documentation specifically recommends against what you're doing:
It is inadvisable to bind handlers to both the
click
anddblclick
events for the same element. The sequence of events triggered varies from browser to browser, with some receiving twoclick
events before thedblclick
and others only one. Double-click sensitivity (maximum time between clicks that is detected as a double click) can vary by operating system and browser, and is often user-configurable.
What you're seeing is exactly what is expected (depending on the browser of course). The only way around your problem is to set a timer and manually differentiate between a single- and double-click yourself; then you'll have to adjust the timer value and check various browsers and operating systems until you get something that sort of pretends to work in most place.
I'd strongly recommend that you use separate controls with single-click actions instead. Double-click is pretty unfriendly period and we only put up with it because we're used to it.
Solution 2:
This isn't an issue with Backbone itself. It's about how to handle both single click and double click events on the same button.
See
Update: But it would be better if you didn't have to deal with it. See mu is too short's answer below!
Solution 3:
Try adding return false;
at the end of select & toggle.
Post a Comment for "Backbone.js - Both Click And Double Click Event Getting Fired On An Element"