I have a problem where my single click events keep interfering with my double click event such that even though I double clicked, the single click event gets called.
Here's my code before a solution I found on SO:
grid.bind('change', function() {
SearchPSelected();
});
$('#PGrid').delegate('tbody>tr', 'dblclick', function(e) {
SearchPSelected();
GotoNextView();
});
Here's my code after I followed a solution on SO:
grid = $('#PGrid').data('kendoGrid');
var DELAY = 700,
clicks = 0,
timer = null;
grid.on("click", function(e) {
clicks++; //count clicks
if (clicks === 1) {
timer = setTimeout(function() {
grid.bind('change', function() {
SearchPSelected();
}); //perform single-click action
clicks = 0; //after action performed, reset counter
}, DELAY);
} else {
clearTimeout(timer); //prevent single-click action
$('#PGrid').delegate('tbody>tr', 'dblclick', function(e) {
SearchPSelected();
GotoNextView();
}); //perform double-click action
clicks = 0; //after action performed, reset counter
}
})
.on("dblclick", function(e) {
e.preventDefault(); //cancel system double-click event
});
With the attempted solution, nothing gets called (with inspection from firebug) and I'm not sure why? I'm still relatively new to js (not my language of choice), so I could be missing something?