josecebe / twbs-pagination

jQuery pagination plugin (bootstrap powered)
http://josecebe.github.io/twbs-pagination/
Other
1.1k stars 401 forks source link

当用ajax 根据某些条件查询数据的时候,实际数据只有一页,但是还是显示之前的页码,怎么解决 #128

Closed xwLyc closed 7 years ago

legendjslc commented 8 years ago

同问,每次查询条件变了,页面总数也应该变了,但前台改变不了?

xwLyc commented 8 years ago

我已经解决了,我是在查询的时候,把页码的那段html清空即可 。然后在查询重新生成页数。 比如我的例子是这样:

$('#search').on('click',function(){
     $(".pageBox").html('<ul id="pagination" class="pagination "></ul>');
     cityList(1);     //这个是ajax 函数 ,实现页码的 
     return false;
});
user20161119 commented 8 years ago

@xwLyc 怎么在方法外面获得当前的页码,比如我在点击下一页的时候,需要把当前的页码传到后台,怎么获取当前选中的页码?

eugenesimakin commented 7 years ago

Possibly, out of date. Closed

Mrli2016 commented 6 years ago

你这个根本不是官方方法……最好还是用官方的渲染方法: var pagination = $('.label_pagination').data('twbsPagination'); if(pagination){ // 当总页数跟配置中的页数不相同时重新渲染下分页组件就行了 if(pagination.options.totalPages !== total){ pagination.options.totalPages = total; $('.label_pagination').twbsPagination('destroy'); } }