jQuery tablesorter how to find sortList object

前端 未结 3 915
清歌不尽
清歌不尽 2021-02-05 13:56

I am using the jQuery tablesorter plugin. I am wanting to store how a user has sorted the table on the page and automatically sort that way the next time the page loads. To do

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 14:43

    You need to bind your table element to the tablesorter sortEnd event. All the data for that object is passed in to the handler. You can then get the current sort like so:

    var currentSort;
    
    $("#yourtableId").tablesorter({
        // initialization
    }).bind("sortEnd", function(sorter) {
        currentSort = sorter.target.config.sortList;
    });
    

提交回复
热议问题