How can I get rid of this Warning
How can I get rid of this Warning

DataTables warning: table id=datatable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
DataTables warning: table id=datatable - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3
Answers
Don't reinitialise the DataTable
.
You are going to have to give us more information if we're going to be able to help though. At least show the code you are using, or, must better, link to a test case showing the issue, per the template text for a new forum post.
Allan
Thanks for your response.
Let's take this code.
I'm just doing some java-script to save the number of list item in the table.
I'm not reinitializing anything I'm just using the table to get the current value to store it.
In this code I get the Warning message.
How can i get the instance without "reinitializing" it?
BTW, the code works fine. Do what I wanted to do, but it gives me the message.
Is that code being loaded more than once on the page, or through some kind of hot reloading (the latter is what I would guess is happening)?
If so do:
Or if it is hot reloading, you might need to do:
If that doesn't help, please link to a test case showing the issue.
Allan
I fixed the problem. If you put "datatable" in the id of the table, the datatable gets initialized automatically, therefor everytime you use it in JavaScript it gives you the warning.
I removed the "datatable" from the id and assign another name like "purchases" or "orders"or whatever and the in JavaScript I initialize the datatable doing this:
In that way I can refer to the table by id without getting the annoying warning message.
Thanks for you help.
There must be something else on your page that is doing that initialisation. DataTables doesn't automatically do initialisation on a page, regardless of what id the
table
has.Allan