n1crack / datatables

Simplify your Datatables server-side processing effortlessly using our lightning-fast PHP library, streamlining your workflow seamlessly.
https://datatables.ozdemir.be/
MIT License
266 stars 89 forks source link

reload trigger alert error #67

Closed itsKnight847 closed 3 years ago

itsKnight847 commented 3 years ago

I trying to edit a row through custom modal and send it to the backend. after row has being edit I trigger the ajax.reload/draw method so the table refreshes

window.DatatableInstanceClosure.ajax.reload(); window.DatatableInstanceClosure.draw();

no matter which I use I still get alert error through after clicking ok the content does refreshes and data is correct but the alert does that on every update.

image

the really strange thing here that the alert doesn't show up when I trigger the reload method when I add a new data to the table, only on data the has being edit.

edit: even if I don't really change the data at all and trigger the server to reload it still alert the same error. one of the most confusing bugs I ever saw with this lib

itsKnight847 commented 3 years ago

for some reason found a solution that works and don't trigger that alert. I don't know why, I don't care why, I wasted many time on this already. hope this helps for future users:

let DatatableInstance = $('#dailyReport').DataTable( { .... }); window.DatatableInstanceClosure = DatatableInstance;

//saved as window instance because of usage at static methods, (not a must)

window.DatatableInstanceClosure.$('tr.selected').removeClass('selected'); window.DatatableInstanceClosure.clear().draw();