reinitialize datatable code example
Example 1: Cannot reinitialise DataTable
$('#dataTable').dataTable({
...
....
"bDestroy": true
});
Example 2: clear datatable initialize once data is fetch
if you're using DataTables 1.10.x, you can initialize the new table with
additional option "destroy": true, see below :
function fetchNews(context)
{
if(context!="")
{
$("#dailyNews").dataTable({
"destroy": true,
});
}
}
OR
For older versions :
function fetchNews(context)
{
if(context!="")
{
$("#dailyNews").dataTable().fnDestroy()
$("#dailyNews").dataTable({
});
}
}