jQuery: The Write Less, Do More JavaScript Library

click() and dblclick(), sitting in a tree

View: New views
2 Messages — Rating Filter:   Alert me  

click() and dblclick(), sitting in a tree

by René-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'd like to bind both events to a div, such that:

When the div is clicked, Event A fires.
When the div is double-clicked, event B fires. But not event A.

The single-click event works fine. And the double-click works too,
except both events fire on double-click. That is, immediately after
the first click (of two), Event A fires....  Then on the second click
of the double-click, event B fires...

Is there a way I can separate the two events?

...Rene

Re: click() and dblclick(), sitting in a tree

by GasGiant :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I wonder if there is a way to cancel an event call? If there is, you
could put a short delay in the click event and add a cancellation of
the click event in the dblclick event. Or, maybe you could use a
toggle for the single click, delay the action, and then the second
click would undo the toggle while it fires dblclick?

I'm just thinking on the fly here :-)
LightInTheBox - Buy quality products at wholesale price!