Tablesorter widgets break the pagination

451
November 22, 2016, at 3:56 PM

Using tablesorter without the widgets, I can set the size attribute in the tablesorterPager and it works well: I can change the table size dynamically, using a dropdown with several values, but if I refresh the page, it displays correctly the number of rows setted with the size attribute. But this behaviour changes if I use the widgets: if I select dynamically a different page size, refreshing the page it doesn't show the default number of rows. This happens simply including the jquery.tablesorter.widgets.js file, without really using any widgets.

The followings are 2 links that show the behaviour:

http://latoclient.it/file1.html

http://latoclient.it/file2.html

The 2 files are identical: the only difference is that in the file2.html I include also the jquery.tablesorter.widgets.js file. I'm using the TableSorter (FORK) 2.18.4, pager plugin v2.21.0 and tableSorter 2.16+ widgets - updated 5/28/2014 (v2.17.1), but I have also tryied with different versions and the result is the same.

The javascript is the following:

<script type="text/javascript">
$(function() {
    $("table")
        .tablesorter().tablesorterPager({
            container: $("#pager"),
            size:5
    });
});
</script>

so I really don't use the widget, but it's simply inclusion raises the issue.

If you select a value different from 5 in the dropdown below the table and refresh the page with F5, the file1.html correctly displays 5 rows, file2.html seems to cache somewhere the previously selected value. This is an unacceptable behaviour for my purposes.

Can you help me to fix this issue, please?

Thank you very much.

Answer 1

The issue you are seeing is because the pager savePages option is set to true by default.

In order for that option to work as expected, you need to include the storage widget, contained in the jquery.tablesorter.widgets.js file. Without the storage widget, the pager is not able to save the last user set page into local storage and/or cookies depending on browser support.

If you don't want the page to "remember" the last user set page size, then set that option to false:

$(function() {
    $("table")
        .tablesorter().tablesorterPager({
            container: $("#pager"),
            savePages: false,
            size:5
    });
});
Rent Charter Buses Company
READ ALSO
jQuery selector by ID not accessing div

jQuery selector by ID not accessing div

I have the following snippet:.

397
Hide a part of an image on hover

Hide a part of an image on hover

Here is what I'm trying to do :[nnn]Have 2 divs one under the other. The bottom one is displaying an image and the up one is let's say white.

357