Dave Methvin schrieb:
>  
>> click works fine
>> when i doubleclick the item the doubleclick gets
>> execute, BUT click gets executed twice BEFORE.
> 
> That's the way the events work. By the time it figures out you wanted a
> double-click, it has already delivered a click.
> 
> You can avoid doing the click action by using setTimeout in the click()
> handler for say 400ms, and only execute the click action if the timer
> expires. Your double-click handler should cancel the timer and perform the
> double-click action. You cannot make the click timeout shorter than the
> double-click time, which in Windows is configurable by the user. So don't
> try to make the click timeout short.

Maybe there is a cleaner solution. From the DOM Level 2 Events Spec:

"If multiple clicks occur at the same screen location, the sequence 
repeats with the detail attribute incrementing with each repetition. 
This event is valid for most elements."

http://www.w3.org/TR/DOM-Level-2-Events/events.html

So you could try to handle single and double click with the click event 
via the event.detail property:

$('#click-me').bind('click', function(e) {
     if (e.detail == 2) {
         alert('Double click');
     } else if (e.detail == 1) {
         alert('Single click');
     }
});

There is no double click in the specification by the way.


-- Klaus

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to