Note: This library works for major modern browsers (with I.E. >= 9)
Basic usage
To install paginator.js:
- Download the zip file containing paginator.min.js and paginator.css (see above links)
bower install --save paginator.js
The basic usage is very simple to configure:
<div id="test">
<article>
...
</article>
<article>
...
</article>
<article>
...
</article>
</div>var pg = paginator.create('#test article');Options
| Option | Description | Default |
|---|---|---|
| appendTo | Choose where to append the pages and links | null (i.e. append to elements' parent) |
| itemsPerPage | Elements per page | 10 |
| displayedPageNumbers | The number of pages' links to show at one moment (interval) | 5 |
| currentPage | Initial page | 1 |
| margins | Number of links to show at the margins | 2 |
| prevText | Previous text | 'Prev' |
| nextText | Next text | 'Next' |
| theme | Choose the theme | 'default' |
Methods
| Method | Description | Parameters | Returns |
|---|---|---|---|
| select | Selects a page given its number | pageNum : Number | { 'link': selected link, 'page': selected page } or null |
| getCurrentPage | Gets the active page | / | Element object |
| previous | Moves to the previous page | / | See select |
| next | Moves to the next page | / | See select |
| pagesCount | Gets the number of pages | / | Number of pages : Number |
| disable | Disables the pagination functionality | / | / |
| enable | Enables the pagination functionality | / | / |
Tests
Tests are written using QUnit and cover all methods. Check them on the GitHub repo.
License
MIT © Ossama Edbali