Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I destroy a datatable

I have datatable and table have ID example.

Now I need to destroy datatable and I write:

$('#example').dataTable().fnDestroy();

but I get:

Uncaught TypeError: Cannot read property 'style' of undefined

also this I get in console log:enter image description here

What is the problem here? Why can't I destroy the datatable? How to solve this?

like image 636
johny mile Avatar asked Feb 26 '15 23:02

johny mile


1 Answers

For latest version of datatables use:

$('#example').DataTable().destroy();

Refer to this for more: https://datatables.net/reference/api/destroy%28%29

For older versions use as stated by Hobo Sapiens:

$('#example').DataTable().fnDestroy();
like image 152
Red Shift Avatar answered Oct 01 '22 17:10

Red Shift