1.0.12 • Published 7 years ago

pagin v1.0.12

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

pagin

A simple pagination library for single page application(SPA).

demo

Installation

npm install --save pagin

or

<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

keydefaultdescription
limit5A number of items per page.
rangePages5A number of pages to display.
recordsKey'records'Path to items in response. If the path does not exist, an empty array is returned. (dot-notation OK. ex.: 'data.records' -> {"data": {"records": }})
totalCountKey'totalCount'Path to the total number of items in response. If the path does not exist, 0 is returned. (dot-notation OK)
sort'id'The item name to be sorted. It is included in the params passed to the callback.
order'desc''asc' or 'desc'. It is included in the params passed to the callback.

API

method/propertydescription
pagin.limitA number of items per page.
pagin.rangePagesA number of pages to display.
pagin.currentPageA number of current pages.
pagin.isLoadingtrue or false. Is it loading?
pagin.sortCurrent sort item name.
pagin.orderCurrent order.
pagin.recordsCurrent items.
pagin.totalCountTotal 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 ''.
1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago