Hello,
I have defined an event in scheduler:
scheduler.attachEvent(“onClick”, function (event_id){
alert("simlpe click: "+event_id);
return true;
});
When I double click one of the existing events e.g. in month mode, the onclick event also fires.
How can I separate this two events?
Thanks for helping,
Imi
The problem is , that browser generates both dbl-click and single click in case of dbl-click action.
The next can be used
[code]scheduler.attachEvent(“onDblClick”, dbl_click)
scheduler.attachEvent(“onClick”, sin_click)
var sin_timer=null;
function sin_click(){
sin_timer = window.setTimeout(real_onclick, 500 );
}
function dbl_click(){
window.clearTimeout(sin_timer);
}
function real_onclick(){
alert(“I’m called only for real single clicks”);
}[/code]
I found that the sin_click() was being called twice creating 2 timeouts, so that when the run line got to dbl_click() it could only clear the lastly assigned sin_timer, and then the first (now out of scope) timer expires to call real_onclick().
var sin_timer = null;
function sin_click()
{
if (sin_timer == null)
sin_timer = window.setTimeout(real_onclick, 500 );
console.log("sin_click="+sin_timer);
}
function dbl_click()
{
window.clearTimeout(sin_timer);
sin_timer = null;
console.log("dbl_click");
}
function real_onclick()
{
console.log("real_onclick");
alert("I'm called only for real single clicks");
}
Prirate arrh, can’t edit my previous post. I forgeot to clear the timer after it fires
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);
}
function dbl_click(event_id, native_event_object)
{
window.clearTimeout(sin_timer);
sin_timer = null;
console.log("dbl_click");
scheduler.showLightbox(event_id);
}
function real_onclick()
{
console.log("real_onclick");
alert("I'm called only for real single clicks");
sin_timer = null;
}