open

Since: Editor 1.0

Form open (display) event - triggered when the form is displayed for user input.
Please note - this property requires the Editor extension for DataTables.

Description

This event is triggered when the form has been instructed to be displayed for end user input. This is triggered by a call to the open(), bubble() or inline() methods (note that open() can be called automatically by create(), edit() and remove()).

This event is triggered after the display controller is instructed to display the form. As such, the form will typically be available in the document (for addition of events, etc, if required) - it is for the two built in display controllers, although it will still be animating into place.

This of the compliment close event.

Event naming / backwards compatibility note

Prior to Editor 1.3, events were prefixed with the string on and this event was called onOpen. That event name can still be used, and will function exactly the same way as the event documented here. The new name is used for simplicity and coherence with the event naming conventions in DataTables.

Type

function( e, method, mode )

Parameters:

Example

Show help messages using field().message() when ctrl+h is typed. Use open and close to listen for this keypress only when the Editor window is shown (display() could also be used).:

var helpShown = false;

editor.on('open', function (e, method, mode) {
	$(document).on('keydown.help', function (e) {
		if (e.keyCode === 72 && e.ctrlKey) {
			// h + ctrl
			if (!helpShown) {
				editor.field('first_name').message("Enter the user's first name");
				editor
					.field('password')
					.message('The password must be at least 8 characters.');
			}
			else {
				editor.field('first_name').message('');
				editor.field('password').message('');
			}

			helpShown = !helpShown;
		}
	});
});

editor.on('close', function () {
	$(document).off('keydown.help');
});

Related

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