Hi,
I noticed. that if I write some code in the onclick && ondblclick. the onclick event will have a high priority to be trigger.
when I double click on the scheduler, the onclick event will always be triggered. scheduler can not distinguish them?
Hi,
I noticed. that if I write some code in the onclick && ondblclick. the onclick event will have a high priority to be trigger.
when I double click on the scheduler, the onclick event will always be triggered. scheduler can not distinguish them?
Hello @lypch ,
This behavior occurs because the browser generates both dbl-click
and single click
in case of dbl-click
action, and the current scheduler implementation can’t avoid it.
If you want to have the code which will run on a real single click, you can use the following workaround:
var sin_timer = null;
function sin_click(event_id, native_event_object)
{
if (sin_timer == null)
sin_timer = window.setTimeout(real_onclick, 500 );
console.log("sin_click="+sin_timer);
return true;
}
function dbl_click(event_id, native_event_object)
{
window.clearTimeout(sin_timer);
sin_timer = null;
console.log("dbl_click");
return true;
}
function real_onclick()
{
console.log("real_onclick");
alert("I'm called only for real single clicks");
sin_timer = null;
}
scheduler.attachEvent("onDblClick", dbl_click)
scheduler.attachEvent("onClick", sin_click)
Here is demo:
http://snippet.dhtmlx.com/5/9c1c7456b
AS you can see, the function real_onclick
will run only after one single click.
Thanks a lot. it’s the solution.