"Create" event?
"Create" event?
EduardoLM
Posts: 2Questions: 0Answers: 0
Please, is there a "create" event on DataTables, that will trigger after DataTables initializes? I'm using version 1.9.4.
Since DataTables makes changes to the DOM, and I'm using DataTables inside a jQueryUI Tabs object, I need to know when DataTables has finished creating itself, so I can make Tabs initialize. If Tabs gets created before DataTables finished it's initialization, things will get messed up. So, I need a way to make DataTables "tell" Tabs it's ready to go.
And more: I need to bind the event AFTER DataTables is created. I know about fnInitComplete, but it seems I can use it only when creating the datatable. And even if there is a way to redefine it later, that won't be enough, because I need a way to add new listeners to the event, not replace it. See this example, this is exactly the way I would call it:
[code]
// Creates a DataTable object, definig some code to run after creation.
$('#example').dataTable(
fnInitComplete: function(oSettings, json) { console.log("This is my default code to run after creation!"); }
);
.
.
.
// Later, I need to bind an extra listener, to run after the one defined above.
$('#example').on(
"datatables_create",
function() { console.log("This is more code I need to run after the default creation one runs!"); }
);
[/code]
Is there something like that in DataTables? If not, is there a way to add it to DataTables?
Many thanks in advance!
Eduardo
Since DataTables makes changes to the DOM, and I'm using DataTables inside a jQueryUI Tabs object, I need to know when DataTables has finished creating itself, so I can make Tabs initialize. If Tabs gets created before DataTables finished it's initialization, things will get messed up. So, I need a way to make DataTables "tell" Tabs it's ready to go.
And more: I need to bind the event AFTER DataTables is created. I know about fnInitComplete, but it seems I can use it only when creating the datatable. And even if there is a way to redefine it later, that won't be enough, because I need a way to add new listeners to the event, not replace it. See this example, this is exactly the way I would call it:
[code]
// Creates a DataTable object, definig some code to run after creation.
$('#example').dataTable(
fnInitComplete: function(oSettings, json) { console.log("This is my default code to run after creation!"); }
);
.
.
.
// Later, I need to bind an extra listener, to run after the one defined above.
$('#example').on(
"datatables_create",
function() { console.log("This is more code I need to run after the default creation one runs!"); }
);
[/code]
Is there something like that in DataTables? If not, is there a way to add it to DataTables?
Many thanks in advance!
Eduardo
This discussion has been closed.
Replies
There is the "init" event, that does exactly what I need, documented here:
http://datatables.net/docs/DataTables/1.9.0/#summary_events
Thank you all very much!
Eduardo