Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: Suppress `click` when `dblclick` is imminent?

Tags:

jquery

events

Let's say I have a <span>. When you single-click this span, I want a save() function to fire. When you double-click the span, I want a rename() function to fire.

If you double-click the span, however, first the click event will fire, then the dblclick event. Since the click precedes dblclick, how can I tell click to not fire save() and instead defer to dblclick where rename() will be fired?

I can probably come up with a few workarounds, but is there any existing functionality in jQuery or previous (code) work that helps me with this already?

like image 263
AgileMeansDoAsLittleAsPossible Avatar asked Jan 21 '11 23:01

AgileMeansDoAsLittleAsPossible


1 Answers

This looks helpful: single and double-click

like image 149
Mike Robinson Avatar answered Oct 18 '22 22:10

Mike Robinson