简单而全功能 jQuery分页系统 分页.js

  • 源码大小:44.93KB
  • 所需积分:1积分
  • 源码编号:19JP-3136
  • 浏览次数:621次
  • 最后更新:2023年05月09日
  • 所属栏目:其他
我要下载
加入收藏
本站默认解压密码:19jp.com 或 19jp_com

简介

Pagination.js是一个强大的、高度可定制和样式化的、基于jQuery的分页系统,用于您的长内容,以提高网页的可读性。

特征:

  • 通过Ajax请求支持本地数据或远程数据。
  • 可自定义的分页文本和数字。
  • 可通过CSS进行完全样式化。
  • 大量的选项/方法/事件来满足您的实际需求。

安装:

  1. # NPM
  2. $ npm install paginationjs --save
  3.  
  4. # Bower
  5. $ bower install paginationjs --save

如何使用它:

1.加载jQuery库和jQuery分页.js文档中的脚本。

  1. <script src="/path/to/cdn/jquery.min.js"></script>
  2. <script src="/path/to/pagination-with-styles.js"></script>

2.调用函数并设置数据源。

  1. $('#demo').pagination({
  2. dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
  3. callback: function(data, pagination){
  4. // template method of yourself
  5. var html = template(data);
  6. dataContainer.html(html);
  7. }
  8. })

3.配置。

  1. $('#demo').pagination({
  2.  
  3. // Data source
  4. // Array | String | Function | Object
  5. dataSource: '',
  6.  
  7. // String | Function
  8. locator: 'data',
  9.  
  10. // Total entries, must be specified when the pagination is asynchronous
  11. totalNumber: 1,
  12.  
  13. // Default page
  14. pageNumber: 1,
  15.  
  16. // entries of per page
  17. pageSize: 10,
  18.  
  19. // Page range (pages on both sides of the current page)
  20. pageRange: 2,
  21.  
  22. // Whether to display the 'Previous' button
  23. showPrevious: true,
  24.  
  25. // Whether to display the 'Next' button
  26. showNext: true,
  27.  
  28. // Whether to display the page buttons
  29. showPageNumbers: true,
  30.  
  31. showNavigator: false,
  32.  
  33. // Whether to display the 'Go' input
  34. showGoInput: false,
  35.  
  36. // Whether to display the 'Go' button
  37. showGoButton: false,
  38.  
  39. // Page link
  40. pageLink: '',
  41.  
  42. // 'Previous' text
  43. prevText: '&laquo;',
  44.  
  45. // 'Next' text
  46. nextText: '&raquo;',
  47.  
  48. // Ellipsis text
  49. ellipsisText: '...',
  50.  
  51. // 'Go' button text
  52. goButtonText: 'Go',
  53.  
  54. // Additional className for Pagination element
  55. //className: '',
  56.  
  57. classPrefix: 'paginationjs',
  58.  
  59. // Default active class
  60. activeClassName: 'active',
  61.  
  62. // Default disable class
  63. disableClassName: 'disabled',
  64.  
  65. //ulClassName: '',
  66.  
  67. // Whether to insert inline style
  68. inlineStyle: true,
  69.  
  70. formatNavigator: '<%= currentPage %> / <%= totalPage %>',
  71.  
  72. formatGoInput: '<%= input %>',
  73.  
  74. formatGoButton: '<%= button %>',
  75.  
  76. // Pagination element's position in the container
  77. position: 'bottom',
  78.  
  79. // Auto hide previous button when current page is the first page
  80. autoHidePrevious: false,
  81.  
  82. // Auto hide next button when current page is the last page
  83. autoHideNext: false,
  84.  
  85. //header: '',
  86.  
  87. //footer: '',
  88.  
  89. // Aliases for custom pagination parameters
  90. //alias: {},
  91.  
  92. // Whether to trigger pagination at initialization
  93. triggerPagingOnInit: true,
  94.  
  95. // Whether to hide pagination when less than one page
  96. hideWhenLessThanOnePage: false,
  97.  
  98. showFirstOnEllipsisShow: true,
  99.  
  100. showLastOnEllipsisShow: true,
  101.  
  102. // Pagging callback
  103. callback: function(){}
  104.  
  105. })

4.公开方法。

  1. // Go to the previous page.
  2. container.pagination('previous');
  3.  
  4. // Go to the next page.
  5. container.pagination('next');
  6.  
  7. // Go to the custom page.
  8. container.pagination('go', 8)
  9.  
  10. // Disable the plugin
  11. container.pagination('disable');
  12.  
  13. // Enable the plugin
  14. container.pagination('enable');
  15.  
  16. // Hide the pagination
  17. container.pagination('hide');
  18.  
  19. // Destroy the plugin
  20. container.pagination('destroy');

5.您可以在上找到完整的文档http://pagination.js.org/docs/index.html.

更新日志:

2023-03-16

  • v2.6.0版本:feat:支持在呈现分页时捕捉错误

2023-03-13

  • v2.5.1版本:错误修复

2022-12-22

  • v2.5.0:fat:支持异步分页的原始响应

2022-12-12

  • v2.4.2版本:错误修复

2022-12-05

  • v2.4.1:修复:大小更改器

2022-12-01

  • v2.3.0版本:feat:支持pageClassName、prevClassName和nextClassName

2019-11-13

  • v2.1.5版本:更新

2018-09-17

  • v2.1.4版本:更新

2018-06-24

  • v2.1.3版本:更新

2018-01-21

  • v2.1.2版本:家务:更新示例、文档和dist文件

2017-11-01

  • v2.1.0版本:家务:更新示例、文档和dist文件

2017-03-21

  • v2.0.8修复:由于使用了“arguments.calleee”,插件无法在严格模式下工作

2015-12-06

  • v2.0.7版本

预览截图