api.on()
Description
Provides a way to attach handlers to internal events.
Usage
api.on(
event: string,
handler: function
config?: { intercept?: boolean, tag?: number | string | symbol }
): void;
Parameters
event- (required) the event that will trigger the handlerhandler- (required) the function to execute when the event occurs (its arguments depend on the specific event)config- (optional) an object that can include:intercept- (optional) settingintercept: truemakes this listener run before otherstag- (optional) a label for the handler, which can be used to remove it later via thedetachmethod
Events
info
You can find the complete list of Kanban internal events here
Example
// create Kanban
const board = new kanban.Kanban("#root", {
columns,
cards
});
// log card data to the console when a card is moved
board.api.on("move-card", ({ id, columnId }) => {
console.log({ id, columnId });
}, {tag: "move"});
Change log: The config.tag and config.intercept options were introduced in v1.7