I have the following snippet to distinguish between clicks and double clicks:
observeSingleAndDoubleClick: function (element, singleClickHandler, doubleClickHandler, timeout) {
var clicks;
$(element).observe('click', function (event) {
++clicks;
if (clicks === 1) {
var timeoutCallback = function (event) {
if (clicks === 1) {
singleClickHandler.call(this, event);
} else {
doubleClickHandler.call(this, event);
}
clicks = 0;
};
timeoutCallback.bind(this).delay(timeout / 1000);
}
}.bind(this));
}
Problem. The event no longer lives when a delay callback is called. Although it works in Firefox, but it is not in IE8. The event object passed to the click handlers is dead because the event has already been passed.
Anyone have any recommendations on how to solve this problem?
source
share