I am using the jQueryFileTree at http://abeautifulsite.net/notebook/58 and I want to distinguish between the dblclick and click events as a click is always triggered by a dblclick.
Googling about led to be a technique in which click is handled by a timer which kicks in when a dblclick does not cancel it.
Is there some way this can be used with jQuery and the jQuery example in an elegant manner?
You can use
setTimeout()
andclearTimeout()
to realize the timer functionality:Look at the following code
Demo goes here http://jsfiddle.net/cB484/
jQuery Sparkle provides a clean elegant solution for this, by implementing a singleclick custom event. By doing this, you can use it just like any other event, so:
It also provides custom events for the last and first clicks of a series of clicks. And the lastclick custom event actually passes the amount of clicks back! So you could do this!
You can find the appropriate demo showcasing what I've just said right here and the source code for defining the custom event right here. It's open source under the AGPL licence, so you can feel free to grab what you need out of it worry free! :-) It's also actively developed on a day to day basis so you will never be short on support.
But most importantly it is a DRY Plugin/Effect Framework to allow you to develop plugins and extensions much more easily. So I hope this helps to achieve that goal!