I'm working on an attendance audit screen which allows the user to single click to confirm the selection and double click to create a report. After I googled for the solution, I found the following solution in stackoverflow.com
Below is the code:
// Someone has created the solution as a delegate to ease the implementation.
$.singleDoubleClick = function (singleClk, doubleClk) {
return (function () {
var alreadyclicked = false;
var alreadyclickedTimeout;
return function (e) {
if (alreadyclicked) {
// double
alreadyclicked = false;
alreadyclickedTimeout && clearTimeout(alreadyclickedTimeout);
doubleClk && doubleClk(e);
} else {
// single
alreadyclicked = true;
alreadyclickedTimeout = setTimeout(function () {
alreadyclicked = false;
singleClk && singleClk(e);
}, 300);
}
}
})();
}
// call this in the document ready:
$('.profile').bind('click', $.singleDoubleClick(confirmSelection, createReport));
Tuesday, 25 December 2012
Subscribe to:
Comments (Atom)
We are moving
We are moving this blog to our new blog site: https://ciysys.com/blog/nodejs.htm
-
Overview Usually, we start developing a new system with designing database and then writing codes. If you are not a fan of ORM, you will h...
-
Below is the sample HTML which will hide the URL at the page header when printing with Javascript. <html moznomarginboxes > ...
-
You can draw a simple pie chart & doughnut chart with SVG + CSS. This is quite simple and straight forward. But the limitation is that i...