JSFiddle - React, Tailwind, and code Playground
by nilesh026
JavaScript
$(".dblclick").single_double_click(function () {
console.log("Try double-clicking me!")
}, function () {
console.log("Double click detected, I'm hiding");
console.log(this)
$(this).editable("php/echo.php", {
data : $(this).data("id"),
indicator : "<img src='img/indicator.gif'>",
tooltip : "Doubleclick to edit...",
event : "dblclick",
onblur : "submit",
style : "inherit",
callback: function(value, settings)
{
$(this).removeAttr('id');$(this).removeAttr('data-id');
$(this).attr('id', value);
$(this).attr('data-id', value);
}
});
})
jQuery.fn.single_double_click = function(single_click_callback, double_click_callback, timeout) {
return this.each(function(){
var clicks = 0, self = this;
jQuery(this).click(function(event){
clicks++;
if (clicks == 1) {
setTimeout(function(){
if(clicks == 1) {
single_click_callback.call(self, event);
} else {
double_click_callback.call(self, event);
}
clicks = 0;
}, timeout || 300);
}
});
});
}