1.0.12 • Published 9 years ago
pagin v1.0.12
pagin
A simple pagination library for single page application(SPA).

Installation
npm install --save paginor
<script src="https://unpkg.com/pagin/dist/pagin.min.js"></script>Usage
// ES2015
import Pagin from 'pagin'
var callback = function(params, success, failure) {
// ajax
}var pagin = new Pagin(callback)or
var options = {
rangePages: 7,
limit: 10,
recordsKey: 'records',
totalCountKey: 'totalCount'
}
var pagin = new Pagin(callback, options)Options
API
| method/property | description |
|---|---|
| pagin.limit | A number of items per page. |
| pagin.rangePages | A number of pages to display. |
| pagin.currentPage | A number of current pages. |
| pagin.isLoading | true or false. Is it loading? |
| pagin.sort | Current sort item name. |
| pagin.order | Current order. |
| pagin.records | Current items. |
| pagin.totalCount | Total number of items. |
| pagin.hasPrev() | Does the previous page exist? |
| pagin.hasNext() | Does the next page exist? |
| pagin.totalPage() | The total number of pages. |
| pagin.toPage(num) | To specified page. num: number of page. |
| pagin.prev() | To previous page. |
| pagin.next() | To next page. |
| pagin.range() | Range of pages to be displayed. |
| pagin.sortBy(key) | Sort by key. |
| pagin.orderBy(key) | 'asc' or 'desc' or ''. |