Double AJAX request with Scroller and bStateSave?

Double AJAX request with Scroller and bStateSave?

anselmlingnauanselmlingnau Posts: 1Questions: 0Answers: 0
edited February 2012 in Plug-ins
I'm using DataTables 1.9.0 with the bundled Scroller extra. I'm getting my table contents from the server via AJAX, and I have enabled bStateSave. All of this works just fine except that when I scroll down and then click a link in the table and then hit the »Back« button in the browser, I'm getting kicked back to the beginning of the table instead of ending up with the same part of the table visible as before clicking the link.

When looking at the XHR requests by means of the Google Chrome development tools, I notice that DataTables makes two XHR requests in a row. The first one appears to ask for the correct region of the table, while the second one asks for the start of the table. The result of the second one ends up being displayed. According to the Chrome network timeline, the second XHR request is started very quickly after the first, long before the first returns any results.

Here's my configuration:
[code]
var table;
$(document).ready(function () {
table = $('#threads').dataTable({
sScrollY: "400px",
sDom: "frtiS",
bServerSide: true,
bStateSave: true,
bDeferRender: true,
sAjaxSource: "/archive/threads/<% list.address %>", /* Perl Template Toolkit syntax */
})
});
[/code]

Does anyone know what is going on?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    There was a small error in Scroller that was causing this I'm afraid. I've just committed a fix, which you can download as the Scroller nightly (1.0.2.dev) from the downloads page: http://datatables.net/download/

    Thanks very much for letting me know about this issue!

    Allan
This discussion has been closed.