Reputation: 197
I'm desperate because I don't find any solution on web for my problem.
I work with easytabs, and on every tab I have a different DataTable with different IDs. On page loading, I've to check, if a DataTable is still there.
On localhost everything works fine, but when i push it on the server I get the following error message:
Uncaught TypeError: Cannot read property 'fnIsDataTable' of undefined
My Code:
if ($.fn.dataTable.fnIsDataTable('#table-history')) {
$('#table-history').DataTable().destroy();
}
I can't explain why it is working on localhost, and any suggestions like "You've to load the jquery before datatable js file" don't solve this issue.
I hope you have any suggestions or experience with it.
Upvotes: 1
Views: 128
Reputation: 2281
Hope this help for you.
As @Eliellel said over here ,What you are trying is : trying to destroy datatable before its creation.
try to replace your function with mine.
if ($.fn.dataTable.fnIsDataTable('#table-history')) {
var table = $('#table-history').DataTable();
if(table){
table.destroy();
}
}
Upvotes: 1