方便 分页插件,带Bootstrap 3/4和jQuery UI 分页.js

  • 源码大小:28.13KB
  • 所需积分:1积分
  • 源码编号:19JP-3359
  • 浏览次数:646次
  • 最后更新:2023年06月04日
  • 所属栏目:其他
本站默认解压密码:19jp.com 或 19jp_com

简介

Pagination.js是一个轻量级但可定制的jQuery插件,用于使用Bootstrap 4或Bootstrap 3分页组件和jQuery UI对大型数据集进行分页。

主要特点:

  • 基于引导分页组件。
  • 使用jQuery UI支持分页滑块。
  • 每次页面点击的回调功能。
  • 允许设置要显示的最大页数。
  • 大量API。

安装:

  1. # NPM
  2. $ npm install s-pagination --save

基本用法:

1.在网页中加载jQuery库和其他所需的JS/CSS文件。

  1. <link rel="stylesheet" href="/path/to/bootstrap.min.css">
  2. <link rel="stylesheet" href="/path/to/jquery-ui.css">
  3. <script src="/path/to/jquer.min.js" ></script>
  4. <script src="/path/to/jquery-ui.min.js"></script>

2.在页面中下载并加载jQuery Pagination.js插件的文件。

  1. <link rel="stylesheet" href="dist/pagination.css">
  2. <script src="dist/pagination.js"></script>

3.创建一个空容器,在该容器上放置分页。

  1. <div id="pagination-demo"></div>

4.在您创建的容器中呈现默认分页的JavaScript。

  1. var myPagination = new Pagination({
  2. container: $("#pagination-demo")
  3. });

5.呈现指定项目计数和页面大小的分页。

  1. var itemsCount = 300;
  2. var itemsOnPage = 10;
  3.  
  4. var myPagination = new Pagination({
  5. container: $("#pagination-demo")
  6. });
  7.  
  8. myPagination.make(itemsCount, itemsOnPage);

6.默认配置选项。

  1. var myPagination = new Pagination({
  2.  
  3. // Where to render this component
  4. container: '',
  5.  
  6. // Called when user change page by this component
  7. // contains one parameter with page number
  8. pageClickCallback: function(){},
  9.  
  10. // The URL to which is browser redirected after user change page by this component
  11. pageClickUrl: '',
  12.  
  13. // If true, pageClickCallback is called immediately after component render (after make method call)
  14. callPageClickCallbackOnInit: false,
  15.  
  16. // The number of visible buttons in pagination panel
  17. maxVisibleElements: 13,
  18.  
  19. // Shows slider for fast navigation between pages
  20. showSlider: false,
  21.  
  22. // Shows text input box for direct navigation to specified page
  23. showInput: false,
  24.  
  25. // The content of tooltip displayed on text input box.
  26. inputTitle: '',
  27.  
  28. // If false, standard mode is used (show arrows on the edges, border page numbers, shorting dots and page numbers around current page).
  29. // If true, standard mode is enhanced, so page number between border number and middle area is also displayed.
  30. enhancedMode: false
  31. });

7.API方法。

  1. // Render the component for specified items count and page size.
  2. // DefaultPageNumber parameter is optional and sets active page.
  3. myPagination.make(itemsCount, itemsOnPage, defaultPageNumber)
  4.  
  5. // Force "Go to page" action. Component is rerendered to specified page and actions (pageClickCallback, pageClickUrl) are invoked.
  6. myPagination.goToPage(pageNumber)
  7.  
  8. // Returns current page count.
  9. myPagination.getPageCount()
  10.  
  11. // Returns current page number.
  12. myPagination.getCurrentPage()

更新日志:

2022-10-11

  • v3.0.0:修复了将默认箭头附加到“goToButtonLabel”

2022-02-18

  • 2.0版本

2022-01-20

  • 添加缺少的容器类型选项

2019-03-07

  • v2.1.0版本

2018-09-27

  • 删除bower,修复与bootstrap 4的兼容性,添加依赖项,更新包版本

2018-01-10

  • 在init上调用回调的选项已移动到Options对象

预览截图