Events
Selectable fires a number of custom events that the instance can listen for.
You can attach a number of custom event listeners using the on()
method and pass the event name and a callback as the first two arguments:
Event listeners can be detached by calling the off()
method with the same arguments:
Both the on()
and off()
methods function the same as the native addEventListener
and removeEventListener
methods respectively.
This means that in order to remove a custom event listener from the instance, you must pass the same function expression to the off()
method as you did to the on()
method - declared / anonymous functions cannot be removed.
Incorrect
Correct
Listening for an event once
Event reference
Name | Description |
---|---|
The instance is ready. | |
The instance has been destroyed | |
An item was added to the instance. | |
An item was removed from the instance. | |
| |
| |
| |
An item was selected. | |
An item was deselected. | |
An item has been marked for selection. | |
An item has been marked for deselection. | |
Save state change. | |
The instance was enabled. | |
The instance was disabled. |
Last updated