javascript - How do I reinitialise a Datatable? -


i have page notifications on want refresh every 10 seconds, don't want reload entire page, reload div contains notifications. notifications in datatable, initialised when page loaded, i've been unable reinitialise datatable when div reloaded. div reloads fine normal table. here code:

$(document).ready(function () {     loadnotificationstable(); });  setinterval(reloadnotificationstable, 10000);  function reloadnotificationstable() {     $('#notificationstable').datatable().fndestroy();      $("#notificationsplaceholder").load(location.href + " #notificationsplaceholder>*", "");      $("#notificationsplaceholder").ready(function () {          loadnotificationstable();     }); };  function loadnotificationstable() {     $('#notificationstable').datatable({         ajax: "data.json",         "blengthchange": false,         'idisplaylength': 1000,         "bsort": false,         "bfilter": false,         "sdom": 'ft<"bottom"ilp>',         "bdestroy": false,         "bpaginate": false,         "binfo":false     }); }; 

is able me , show me i'm doing wrong?

try re-initializing datatable after load has finished in callback:

$("#notificationsplaceholder").load(location.href + " #notificationsplaceholder>*",function(data){     loadnotificationstable(); }); 

also add initialization code since want replace table

https://legacy.datatables.net/ref#bdestroy

"bdestroy": true, 

Comments

Popular posts from this blog

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -