Request for initDataTable() / destroyDataTable() event
Request for initDataTable() / destroyDataTable() event
Loren Maxwell
Posts: 406Questions: 99Answers: 10
I've recently started to use the initEditor
function to attach some events to all editors I use on my site, such as:
$(document).on( 'initEditor', function ( e, inst ) {
// Attach an 'open' event to all Editors
inst.on( 'open', function () {
// Perform some formatting or whatever
});
});
This has helped me with this question: https://datatables.net/forums/discussion/76507/on-open-event-for-all-editors
A similar initDataTable
and a corresponding destroyDataTable
would be amazing!:
$(document).on( 'initDataTable', function ( e, inst ) {
// Attach an 'open' event to all DataTables
inst.on( 'open', function () {
// Perform some formatting or whatever
});
});
This question has accepted answers - jump to:
Answers
There is
initComplete
andinit
that are used when Datatables is initialized. Is that what you are looking for?Will let @allan comment on the
destroyDataTable
event.Kevin
@kthorngren -- thanks, Kevin --
initComplete
andinit
will work but I'd have to add the common// Perform some formatting or whatever
to each table:I'm hoping for a DataTables event on each DataTable creation so that i can then add those events to each new table.
However mentioning
-event
does draw my attention to a copy and paste mistake in my example above.It should be:
Possibly you can use a selector that covers all the Datatables similar to this example.
https://www.datatables.net/examples/basic_init/multiple_tables.html
You may need to add the ‘dt’ namespace for example ‘init.dt’.
Kevin
Both
init
anddestroy
bubble, so:Would do what you are looking for.
Allan
Ah, awesome! Thanks, @kthorngren and @allan!