Reset total pages in jquery pagination plugin

后端 未结 5 475
你的背包
你的背包 2021-02-04 05:42

I am using TwbsPagination plug in for displaying paging in my app. It is working fine when we set the page size while initializing. However, based on the search result, I want t

5条回答
  •  遥遥无期
    2021-02-04 06:34

    After analyzing the script code i get to know that this script uses .data() method to save view state of the pagination and i managed to do it explicitly.

    .data(): Store arbitrary data associated with the matched elements or return the value at the named data store for the first element in the set of matched elements. ref: http://api.jquery.com/data/

    Solution to reset pagination.

    you just need to call before your "list rendering" OR "data binding" funciion / method

    $('#pagination').empty();

    $('#pagination').removeData("twbs-pagination");

    $('#pagination').unbind("page");

    and this will reset view state data of the pagination. ("twbs-pagination" is the view state key).

提交回复
热议问题