I\'m writing event handlers using jQuery, and had a question about the click and double-click events. I\'ve got an element with a class \"file\" on it. It has two event handlers
As James mentions in his comment, there cannot be one without the other. It's going to be a bit of a hack, but you can have these work independently with a timer:
$('.file').live('dblclick', function() {
$(this).data('doubleClicked', true);
//event handler code
});
function SingleClickHandle(this)
{
if (! $(this).data('doubleClicked'))
{
//event handler code
}
}
$('.file').live('click', function(){
$(this).data('doubleClicked', false);
setTimeout('SingleClickHandler(this)', 500); // is half a second enough to consider it a double-click?
});