Datatable initialization bugs out, but only when using the back button in the browser

Datatable initialization bugs out, but only when using the back button in the browser

raquoraquo Posts: 7Questions: 3Answers: 0

Ok, this is a weird one. Everything works as intended if I just enter the page normally. Table renders absolutely fine. I can then navigate to another page, and if I then press the back button to return I get this error message:

DataTables warning: table id=tableorderrows - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

The console adds this error message (repeated twice):
Uncaught TypeError: Cannot read property 'aDataSort' of undefined
at _fnSortFlatten (datatables.js:5901)
at _fnSort (datatables.js:5952)
at _fnReDraw (datatables.js:3544)
at _Api.<anonymous> (datatables.js:7465)
at _Api.iterator (datatables.js:7041)
at _Api.<anonymous> (datatables.js:7454)
at _Api.draw (datatables.js:7208)
at showOrderRows (DeliveryOutAdd.cshtml?deliveryId=699:11789)
at Object.<anonymous> (DeliveryOutAdd.cshtml?deliveryId=699:14546)
at c (jquery-3.4.1.min.js:2)

I tried messing about with the order option since google searches led me in that direction, but to no avail.

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    As the technote http://datatables.net/tn/3 states you are reinitializing Datatables with options after it has been initialized. The technote provides troubleshooting steps. If you still need help please post a link to your page or a test case replicating the issue so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • raquoraquo Posts: 7Questions: 3Answers: 0

    Thanks, we got it working. The problem was that the page works absolutely fine normally, it only bugged out when using the back button.

    We suspect Chrome might have changed something with their cache handling or something. We tried to declare the datatable object outside of document.ready, and then it worked.

This discussion has been closed.