detachAllEvents

detaches all events from dhtmlxGantt (both custom and inner ones)

void detachAllEvents();

Deprecated

instead of it, you can use:

// save handler ids when attaching events
var events = [];
events.push(gantt.attachEvent("onTaskClick", function(id, e) {
    alert("You've just clicked an item with id="+id);
});
events.push(gantt.attachEvent("onTaskDblClick", function(id, e) {
    alert("You've just double clicked an item with id="+id);
});
 
// detach all saved events
while (events.length)
   gantt.detachEvent(events.pop());

Example

var event1 = gantt.attachEvent("onTaskClick", function(id, e) {
    alert("You've just clicked an item with id="+id);
});
var event2 = gantt.attachEvent("onTaskDblClick", function(id, e) {
    alert("You've just double clicked an item with id="+id);
});
 
var events = [];
events.push(event1);
events.push(event2);
 
for (var i=0; i<events.length; i++)
   gantt.detachEvent(events[i]); events = [];

Details

Note, using the method can break the functionality of dhtmlxGantt, as it removes ALL event handlers at a time: those defined by a custom logic and those defined by dhtmlxGantt itself (to link different parts and functionality).

A safer approach is to store the result of the attachEvent method and to use the detachEvent method to detach saved events when necessary, as shown in the example above.

See also
Back to top