one()

Since: Editor 1.3

Listen for an event once and then remove the 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 one() method is used to listen for an event from Editor and then immediately remove that event once it has fired for the first time. Simply pass in the event you wish to listen for and provide a callback function which will be activated, and then removed, when the event is triggered by Editor.

Type

one( event, callback )

Add an event listener, for which the callback will be fired once only and then the event listener removed.

Parameters:

Returns:

DataTable.Editor: Editor instance

Example

Show an alert the first time the form is displayed:

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