cannot reinitialize datatable error also with retrieve option true
cannot reinitialize datatable error also with retrieve option true
hello!
i'm creating a module for processwire and everything is working really well. i have one big problem though:
i'm initializing my table via the module, taking care of adding buttons, filter options and the like
// DataTablesGlobal.js
$(document).ready(function() {
$table = $('#todo-details');
// some options here like preparing "defs" array
// all other options come from HTML data attributes
$table.DataTable({ columnDefs: defs });
}
then i want to be able to do some kind of stuff with this initialized table from another javascript file
// todo-details.js
$(document).ready(function() {
$table = $('#todo-details');
datatable = $table.DataTable({retrieve: true});
}
this throws an error pointing me to this site: datatables.net/tn/3
but that does not help me... any help? how can i get my datatable instance without the error?
thank you!
This question has an accepted answers - jump to answer
Answers
The "Diagnosis" section at datatables.net/tn/3 seems pretty clear to me. It even shows a code example quite similar to your own code,
Your code looks like it should work to me. We'd need need a link to a page showing the issue to be able to help diagnose why it isn't working. Probably execution order.
Allan
wow, thank you allan for your quick response and all your work you put into this great piece of software!! it's really making my project for a client worlds better than i ever thought.
i solved the problem when trying to setup a test installation for you, so your answer that it "should" work helped me
the reason for the message was that i did not control the ORDER of the script tags, meaning i had something like this:
so this led to this calls:
then the error message totally makes sense. maybe you can add a hint to the error docs page that one should take care of loading order if the code is split up in several files
thanks again and all the best!
That would do it. Nice one spotting that and thanks for letting me know that it is resolved.
Allan