Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Mike H on Feb 26, 2009 08:41
open dhtmlx forum
Grid onRowSelect called TWICE in Firefox

Hi,

It appears that when you double click a grid row, it actually calls the onRowSelect event twice in Firefox. This does NOT happen in IE.

This was easily proven using a counter variable in the event handler function. The problem is that it is impossible for me to use the onDblClick event successfully even using the setTimeout/clearTimeout trick, because the onRowSelect gets called twice and only one timer gets cleared. Is there any known workaround to this??
Answer posted by Support on Feb 26, 2009 15:13
The grid use direct approach - each onclick event on row will generate onRowSelect event.
Unfortunately FF generates next set of events when mouse dbl-clicked - onclick, onclick, ondblclick - which result in double call of onRowSelect event.

>>Is there any known workaround to this??

var timer_func=null;
mygrid.attachEvent("onRowSelect",function(){
     window.clearTimeout(timer_func);
     timer_func = window.setTimeout(function(){
                     any code for single-click here
     },300);
}
mygrid.attachEvent("onRowDblClick",function(){
     window.clearTimeout(timer_func);
     any code for dbl-click here
});

})
Answer posted by Mike H on Feb 26, 2009 15:56
Yes, that is exactly the code I use.

In Internet Explorer, it results in ZERO executions of the Single Click event call, and ONE execution of the Double Click event call, which is the desired behavior.

However in Firefox, it results in ONE execution of Single click event call, and ONE execution of the Double click event call, which is problematic.

How can I get ZERO single click event calls in Firefox?

Thanks!
Answer posted by Support on Feb 27, 2009 03:57
Sorry for inconvenience, it really requires a bit more complex code. 
Please check attached sample. 
Attachments (1)
Answer posted by Mike H on Feb 27, 2009 05:38
AH just one little extra line does the trick! Thanks!