Event Handling

To handle events of Ribbon and its TreeCollection, use the methods of the events module.

Attaching event handlers

You can add any handler to the events of Ribbon and its TreeCollection. To do this, use the ribbon.events.on() method with the following parameters:

  • the name of the event,
  • a user-defined event handler.
ribbon.events.on("Click", function(id,e){
    console.log(id,e);
});

Several handlers can be attached to one and the same event, and all of them will be executed.

The names of the events are case-insensitive.

Detaching event handlers

There is a simple way of removing an event-handler. Call the ribbon.events.detach() method:

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

Calling events

You do not need to call events of Ribbon and its TreeCollection. Yet, you can call any custom event with 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.

Back to top