blur()

Since: Editor 1.3

Blur the currently displayed editor.
Please note - this property requires the Editor extension for DataTables.

Description

An Editor blur is very similar to a close (see close()) as they can both trigger the form to be closed, however, a blur is an indirect operation, while a close is a direct and immediate operation. For example, when the Editor lightbox display controller is shown, the end user can directly close the form by clicking on the close icon in the top right, or the form can potentially be closed by clicking on the background of the HTML document - this is a blur.

Additionally, the blur action's behaviour can be modified by the form-options options that are used to display the form. For example, the form-options.submitOnBlur option can be used to have the form automatically submit when blurred. This can be useful when using inline() particularly if keyboard navigation is your primary input method.

This method will primarily be of use to developers who wish to create their own display controller, and want to be able to offer the same functionality of the built in controllers, with regard to being able to close and blur a form.

Type

blur()

Trigger a form blur, closing the form or submitting depending on the configuration.

Returns:

DataTable.Editor: Editor instance

Example

Blur the form on click of a selected element:

var editor = new DataTable.Editor({
	ajax: 'php/index.php',
	table: '#example',
	fields: [
		{
			label: 'Name',
			name: 'full_name'
		}
	]
});

// Display the form
editor
	.title('Create record')
	.buttons({
		label: 'Save',
		fn: function () {
			this.submit();
		}
	})
	.create();

// Close on click of a given element
$('#blurForm').on('click', function () {
	editor.blur();
});