• Stars
    star
    903
  • Rank 50,580 (Top 1.0 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A jQuery plugin to provide simple yet fully customisable pagination.

Pagination.js

A jQuery plugin to provide simple yet fully customisable pagination.

NPM version Bower version CDNJS

paginationjs

See demos and full documentation at official site: http://pagination.js.org

Installation / Download

npm install paginationjs or bower install paginationjs or just download pagination.js from the git repo.

Quick Start

<div id="data-container"></div>
<div id="pagination-container"></div>
$('#pagination-container').pagination({
    dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
    callback: function(data, pagination) {
        // template method of yourself
        var html = template(data);
        $('#data-container').html(html);
    }
})

Rendering data

Below is a minimal rendering method:

function simpleTemplating(data) {
    var html = '<ul>';
    $.each(data, function(index, item){
        html += '<li>'+ item +'</li>';
    });
    html += '</ul>';
    return html;
}

Call:

$('#pagination-container').pagination({
    dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
    callback: function(data, pagination) {
        var html = simpleTemplating(data);
        $('#data-container').html(html);
    }
})

To make it easier to maintain, you'd better to use specialized templating engine to do that. Such as Handlebars and Undercore.template.

Handlebars

<script type="text/template" id="template-demo">
    <ul>
    {{#each data}}
        <li>{{this}}</li>
    {{/each}}
    </ul>
</script>
$('#pagination-container').pagination({
    dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
    callback: function(data, pagination) {
        var html = Handlebars.compile($('#template-demo').html(), {
            data: data
        });
        $('#data-container').html(html);
    }
})

Underscore

<script type="text/template" id="template-demo">
    <ul>
    <% for (var i = 0, len = data.length; i < len; i++) { %>
        <li><%= data[i] %></li>
    <% } %>
    </ul>
</script>
$('#pagination-container').pagination({
    dataSource: [1, 2, 3, 4, 5, 6, 7, ... , 195],
    callback: function(data, pagination) {
        var html = _.template($('#template-demo').html(), {
            data: data
        });
        $('#data-container').html(html);
    }
})

Or any other templating engine you prefer.

License

Released under the MIT license.

MIT: http://rem.mit-license.org, See LICENSE

More Repositories

1

redux-saga-in-chinese

Redux-saga 中文文档
634
star
2

puzzler

一个高效快速的前端页面切图工具,用于将一张图片快速切割成切片并导出 HTML 文件,所有的工作都通过可视化拖拽完成,让你从重复的 PSD 切图工作中解放出来。
JavaScript
348
star
3

react-native-alipay

基于 React Native 实现的支付宝钱包 UI 界面
JavaScript
164
star
4

rock-markdown-editor

Cross-platform Markdown Editor
JavaScript
114
star
5

image-clipper

Node.js module for clipping & cropping JPEG, PNG, WebP images purely using the native Canvas APIs, excellent compatibility with the Browser & Electron & NW.js (Node-webkit), itself doesn't relies on any image processing libraries.
JavaScript
77
star
6

image-to-slices

Node.js module for converting image into slices with the given reference lines.
JavaScript
35
star
7

xss-filter

XSS (Cross-Site Script) Filter for Node.js & the browser, provides friendly, reliable XSS filter API for you.
JavaScript
20
star
8

gitlab-db

A lightweight Gitlab based JSON database with Mongo-style API.
JavaScript
8
star
9

slices

Node.js module for slicing given area into blocks with the given reference lines. 🍴 🍰
JavaScript
8
star
10

gulp-banner

A gulp plugin to insert a comment (or other string) at the top of the file.
JavaScript
5
star
11

pure-css-multi-level-menu

纯 CSS 实现的无限制级联菜单
CSS
4
star
12

superraytin.github.io

Leon's blog
CSS
4
star
13

underscore.template

Extracted template from Underscore, use "_.template" without full underscore source.
JavaScript
4
star
14

file-content-matcher

Search files recursively using content match.
JavaScript
3
star
15

github-style-page

Converting markdown content into HTML file with Github styles (GFW).
HTML
3
star
16

paginationjs-site

Website for http://pagination.js.org
CSS
2
star
17

light-pub-sub

Light pub/sub library for Javascript
JavaScript
2
star
18

Chopper

A Light Microblog System Based on Nodejs -- 轻量的多用户微博系统
JavaScript
2
star
19

node-comparev

Easily compare versions numbers (semver version)
JavaScript
1
star
20

duckJS

A Module Loader For JavaScript - Javascript模块加载器
JavaScript
1
star
21

RaytinJS

A Lightly JavaScript Library - 轻量的Javascript类库
JavaScript
1
star
22

jquery-countdown

jQuery countdown plugin.
1
star
23

douban-fm-shell

A shell for http://douban.fm
HTML
1
star
24

nodejs-socket-chat-demo

Node.js + Socket.io chat room demo
JavaScript
1
star
25

eventemitter-callback

Emit an event and waiting for a result.
JavaScript
1
star
26

roller

jQuery scroll Timing Solutions - jQuery定时滚动解决方案
1
star
27

html-webpack-simple-inject-plugin

Injects a custom string into the html-webpack-plugin output.
JavaScript
1
star
28

onlineTools

Better Online Tools For Programmers - 妈妈再也不用担心我找不到在线好工具啦beta2.0 (开发中)
CSS
1
star