off()

Since: Editor 1.0

Remove an event listener.
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:

  • on() - Listen for events
  • off() - Stop listening for events
  • one() - Listen for a single event.

This off() method is used to remove a listener that has already been attached to a Editor. Simply pass in the event you wish to remove the listener, and optionally the specific function if you want to remove only a single event listener.

Type

off( name [, fn ] )

Remove an event listener from the Editor instance

Parameters:

Returns:

DataTable.Editor: Editor instance

Examples

Add an event to alert when the form is shown and then remove:

editor.on('open', function () {
	alert('Form displayed!');

	editor.off('open');
	// could also have used `editor.one()` to obtain this effect
});

Client-side validation using preSubmit:

editor.on('preSubmit', function () {
	if (this.get('first_name') === '') {
		this.error('first_name', 'This field is required');
		return false;
	}

	return true;
});