template()

Since: Editor 1.6.2

Get / set the template element to use for the main form.
Please note - this property requires the Editor extension for DataTables.

Description

This method provides the ability to programmatically control the element that Editor will use to display its main form (see template).

Please note that if you overwrite an existing template node and want to be able to use it again in future, you will need to use this function as a getter initially to store it in a variable that can be reused when required. Without doing this, or inserting the element back into the document, it would be garbage collected by the browser.

Types

template()

Get the currently set template element.

Returns:

Dom or null:
Dom object that contains the template element. Will be null if there is no template set.

        Please note that prior to Editor 3, this method would return a `jQuery` instance.

template( element )

Set the element to use for the Editor main editing template.

Parameters:

Returns:

DataTable.Editor: Editor instance

Example

Set the template based on a user's access rights:

if (accessRights === 'admin') {
	editor.template('#admin');
}
else {
	editor.template('#developer');
}

Related

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