initEditor
Editor instance created.
Please note - this property requires the Editor extension for DataTables.
Description
Generally you don't need to know programmatically when a new Editor instance is created, since you use new DataTable.Editor(...); to create a new instance and any dependent code can follow. However, it can be useful to apply common actions, event handlers or even for testing to multiple Editor instances, and this event provides that ability.
Note that unlike the other Editor events, do not listen for it on the Editor instance (since you don't know what that is!), but rather on the document element. The Editor instance that was created is passed in as the second parameter to the callback function.
Type
function( e, inst )
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | e | No | |
Event object | |||
| 2 | inst | No | |
The Editor instance that was created. | |||
Examples
Get the row information for each row to be edited - multi-row editing:
$(document).on('initEditor', function (e, inst) {
inst.on('opened', function () {
console.log('Form displayed');
// ... add event handlers
});
});Maintaining a collection of existing Editor instances:
const pool = [];
$(document)
.on('initEditor', function (e, editor) {
pool.push(editor);
})
.on('destroyEditor', function (e, editor) {
let idx = pool.indexOf(editor);
if (idx >= 0) {
pool.splice(idx, 1);
}
});Related
The following options are directly related and may also be useful in your application development.