on

Since: Editor 3.0

Add event listeners to Editor during initialisation.
Please note - this property requires the Editor extension for DataTables.

Description

Similar to DataTables, Editor has an extensive collection of events that you can listen for using the on() method and then take action when triggered. Although Editor doesn't trigger many events without user interaction, it can be useful to assign event handlers during initialisation. This option matches DataTables' own on option in that regard.

Any event name that is given in the list of events can be used as the object property name, while the value may take a callback function as the event handler.

The arguments passed to the event handlers are identical to those for the event identified by the property name.

Type

This option can be given in the following type(s):

Default

null

Examples

Listen for the open event:

new DataTable.Editor({
	on: {
		open: (e, mode, action) => {
			console.log('Editor form opened');
		}
	},
	// ...
});

Using preSubmit:

new DataTable.Editor('#example', {
	on: {
		preSubmit: (e, data, action) => {
			data.extra = 1;
		}
	},
	...
});

Related

The following options are directly related and may also be useful in your application development.