Skip to main content

Event handling

Attaching event listeners​

You can add a custom handler to any available event with the dataview.events.on() method. The method takes the following parameters:

evNamethe event name
evHandlera custom event handler
dataview.events.on("click", function(id, e){
console.log("The item with the id "+ dataview.selection.getId(id) +" was clicked.");
});

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

note

Event names are case-insensitive.

Related sample: Dataview. Events

Detaching event listeners​

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

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

dataview.events.detach("click");

Calling events​

The dataview.events.fire() method calls an event:

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

List of supported events​

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