Skip to main content

Event handling

Use the methods of the events module to handle Ribbon and TreeCollection events.

Attaching event handlers​

You can add a custom handler to any event of Ribbon and its TreeCollection with the ribbon.events.on() method. The method takes the following parameters:

evNamethe event name
evHandlera custom event handler

ribbon.events.on("click", function(id,e){
console.log(id,e);
});

You can attach several handlers to the same event, and Ribbon runs all of them.

note

Event names are case-insensitive.

Related sample: Ribbon. Events

Detaching event handlers​

The ribbon.events.detach() method removes an event handler:

ribbon.events.on("click", function(id,e){
console.log(id,e);
});

ribbon.events.detach("click");

Calling events​

Ribbon and its TreeCollection fire their events automatically. To call a custom event, use the fire() method of the events module:

ribbon.events.fire(evName,[parameters]);

List of supported events​

You can find the full list of Ribbon events in the related API section.