Перейти к основному содержимому

detach()

Описание

Отсоединяет обработчик от события (ранее привязанный методом on())

Использование

detach(name: string): void;

Параметры

  • name - (обязательный) имя события, от которого нужно отсоединить обработчик

Пример

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

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

spreadsheet.events.detach("StyleChange");
К сведению

По умолчанию detach() удаляет все обработчики целевого события. Можно отсоединить конкретные обработчики с помощью маркера контекста.

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);

Полезная статья: Обработка событий