on()
Listen for an Editor event.
Please note - this property requires the Editor extension for DataTables.
Description
Editor triggers a number of custom events which can be useful for taking action when those events occur. For example, it can be useful to know when a form is opened through the open event.
Editor provides three methods for working with Editor events, matching the core jQuery event methods:
This on() method is used to start listening for Editor events. Simply pass in the event you wish to listen for and provide a callback function which will be activated when the event is triggered by Editor.
Type
on( event, callback )
Attach an event listener to the Editor instance
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | event | No | |
Event to listen for. Multiple events can be listened for using a space separator and events can be namespaced, just like with | |||
| 2 | callback | No | |
Event callback handler. For the argument list passed in, please refer to the documentation for the event that you are using. | |||
Returns:
DataTable.Editor: Editor instance
Examples
Add an event to alert when the form is shown:
editor.on('open', function () {
alert('Form displayed!');
});Log events on the console when they occur:
editor.on('open', function () {
console.log('Form opened');
});
editor.on('close', function () {
console.log('Form closed');
});
editor.on('submit', function () {
console.log('Form submitted');
});