2017-06-20 54 views
1

我是新来的分页插件,现在我决定使用jQuery TWBS分页插件。jQuery TWBS分页实现

我看到了不同的教程,但实际上我找不到如何获取数据到这个插件,并设置我想显示每页适当数量的div。 我的HTML看起来像这样:

<div class="wrapper"> 
    <div class="container"> 
    <div class="row"> 
     <div class="col-sm-12"> 
     <ul id="pagination-demo" class="pagination-sm"></ul> 
     </div> 
    </div> 
    <div id="page-content" class="page-content"> 
     <div class="content">Some text</div> 
     <div class="content">Some text</div> 
     <div class="content">Some text</div> 
     <div class="content">Some text</div> 
     <div class="content">Some text</div> 
    </div> 
    </div> 
</div> 

和JS应该是这样的:

$('#pagination-demo').twbsPagination({ 
     totalPages: 2, 
     next: 'Next', 
     prev: 'Prev', 
     onPageClick: function (event, page) { 
      //fetch content and render here 
      $('#page-content').text('Page ' + page) + ' content here'; 
     } 
    }); 

我不明白我怎么能取我的div“内容”类名来此onPageClick功能并且每个页面只显示4个div。

我知道这是非常简单的事情,但我不能自己做。请帮助。

回答

1

Docs

twbsPagination插件不支持itemOnPage

对于备用分页方法,他们所提出的建议使用flaviusmatis/simplePagination.js

希望这有助于!

+0

Hi @Mahesh Singh Chouhan。感谢您的快速反馈。 其实,我终于停止了浪费我的时间:) 我检查了你的意见flaviusmatis/simplePagination.js并且低文档也有同样的问题。 但是经过一番搜索之后,我发现了这篇完美的文章,在这篇文章中,开发者解释了如何在示例中使用这个simplePagination插件。 也许这对未来的人会有所帮助。 http://www.bilalakil.me/simplepagination/ 您可以使用本指南进行分页和每页项目选项。 –