Reset total pages in jquery pagination plugin

后端 未结 5 524
你的背包
你的背包 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:17

    Read the twbs-pagination source code

    here tells why you failed to reset total page :

        var data = $this.data('twbs-pagination');
    
        if (!data) $this.data('twbs-pagination', (data = new TwbsPagination(this, options) ));
    

    Viewstate param twbs-pagination exists, so you cannot re-render.

    here is the solution to delete viewstate:

    TwbsPagination.prototype = {
    
        destroy: function () {
            this.$element.empty();//remove child nodes
            this.$element.removeData('twbs-pagination');//remove viewstate
            this.$element.off('page');//unbind $(this) node from page
            return this;
        },
    

    So you can call destroy method @Robin Carlo Catacutan

    OR manually execute inner method @Vipin Kohli

提交回复
热议问题