Categories | Question details Back To List | ||
Detach Event on dhtmlxGrid I am working on an application wherein I attach a mouse over event to a grid. var eventId = grid.attachEvent("onMouseOver",function(id,ind) { ......... return false; }); Based on a condition I detach the same event from this grid. if (...) grid.detachEvent(eventId); I cannot get the above to work. Am I missing something here? Thanks, Rahul Kulkarni Answer posted by dhxSupport on May 11, 2009 04:12 Could you please provid us any kind of sample where we can reproduce this issue? Probably issue appears because of you using local variable for event id (var eventId) and when you are trying detach event, "eventId" variable is not defined. Answer posted by Rahul Kulkarni on May 11, 2009 05:00 I have the following error handler which defines and attaches to a grid the mouseOver event. function processErrors(r,c,message) { grid.setRowColor(grid.getRowId(r),"yellow"); grid.cellByIndex(r,c).cell.style.color="red"; grid.cellByIndex(r,c).cell.style.fontWeight="bold"; var eventId = grid.attachEvent("onMouseOver",function(id,ind) { this.cellByIndex(r,c).cell.title=message; return false; }); eventsArray[eventsArrayIndex++] = eventId; } I have another function which after a user has seen the errors from above, clears the mouseOver events. function clearErrors() { for (var i=0;i<eventsArray.length;i++) { //when I add an alert here I do see the events that I had attached previously. grid.detachEvent(otlGlobals.eventsArray[i]); } } Both the eventsArray and eventsArrayIndex are globally defined. Answer posted by dhxSupport on May 11, 2009 06:56 We have tested your code and it works perfect if modify clearErrors() function like that: function clearErrors() Answer posted by Rahul Kulkarni on May 11, 2009 10:47 I am sorry about the typo in my clearErrors(). I do use it the way your email shows it. The mouseOver events don't detach though. I am using v.1.6 build 80603 if that helps in any way.. Thanks. Answer posted by dhxSupport on May 12, 2009 06:20 Could you please send us example where we can reproduce this issue including files which you are using to init grid. |