Skip to main content

detach()

Description

Detaches a handler from an event (which was attached before by the on() method)

Usage

detach(name: string): void;

Parameters

  • name - (required) the name of event to detach

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet", {
// config parameters
});

spreadsheet.events.on("StyleChange", function(id){
console.log("The style of cell "+spreadsheet.selection.get()+" is changed");
});

spreadsheet.events.detach("StyleChange");
info

By default detach() removes all event handlers from the target event. You can detach particular event handlers by using the context marker.

const marker = "any"; // you can use any string|object value

spreadsheet.events.on("StyleChange", handler1);
spreadsheet.events.on("StyleChange", handler2, marker);
// the next command will delete only handler2
spreadsheet.events.detach("StyleChange", marker);

Related articles: Event Handling