tablesorter
tablesorter copied to clipboard
Using saveSort and initialSort together results in uncorrect behaviour
Hey,
So I noticed that if you use saveSort
and initialSort
together it doesn't work correctly.
Steps to reproduce:
- Use the following config
tableSorterConfig = {
forceLoad: true,
widgets: ['uitheme', 'saveSort'],
widgetOptions: {
saveSort: true,
},
sortList: [[2,1]],
}
- Go to the page and sort by any other columns except [2, 1]
- Refresh the page
- Table is sorted correctly by the column you previously sorted by
- Refresh the page
- Table was sorted by the initialSort
Expected behaviour should be when you refresh the page for the 2nd time it should still be sorted by the sort settings saved in localStorage.
Hi @matjaz321!
Hmm, that is strange.
When I test it in this demo - https://jsfiddle.net/Mottie/bbxxomhx/2031/ - I see the saved sort is restored every time, but only if I use the "Run" button at the top. If I reload the page completely, it uses the sortList
, and the saved sort isn't found in local storage. I think it may be a quirk of JSFiddle since the storage values are there when I look, but not initially? No idea.
When I create the same demo locally, it consistently restores the saved sort.
So, I guess I can only think of recommending that these two things are checked:
-
Make sure the
storage
widget has been loaded. It's included in thejquery.tablesorter.widgets.js
file, but you'll need to include it if you usesaveSort
from outside of that file. -
Check to make sure the storage is being saved; Open up the dev tools and look in the application tab > local storage