Skip to main content

Event handling

Attaching event listeners

The user can add any user-defined handler to any of the available events. To do this, the user can use the list.events.on() method with the following parameters:

evNamename of the event
evHandleruser-defined event handler
list.events.on("click", function(id, e){
console.log("The item with the id "+ list.selection.getId(id) +" was clicked.");
});

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

note

The names of the events are case-insensitive.

Related sample: List. Events

Detaching event listeners

There is a simple way of removing an event handler via the list.events.detach() method:

list.events.on("click", function(id, e){
console.log("The item with the id "+ list.selection.getId(id) +" was clicked.");
});

list.events.detach("click");

Calling events

To call events, use list.events.fire():

list.events.fire("name",args);
// where args is an array of arguments

List of supported events

You can find the full list of List events in the API Reference.