Note: The pagination plugin is deprecated since v1.5.0, it's now bundled into List.js.
To use the plugin you first need to download it:
bower install list.pagination.js
<script src="//cdnjs.cloudflare.com/ajax/libs/list.pagination.js/0.1.1/list.pagination.min.js"></script>
<div id="listId">
<ul class="list">
// A bunch of items
</ul>
<ul class="pagination"></ul>
</div>
<script>
var options = {
valueNames: [ 'name', 'category' ],
page: 3,
plugins: [
ListPagination({})
]
};
var listObj = new List('listId', options);
</script>
listObj.pluginName
.
ul
that should contain the pagination (must be inside the list container)
innerWindow: 2 … 3 4 5 6 7 …
innerWindow: 1 … 4 5 6 …
outerWindow: 0 … 3 4 5 6 7…
outerWindow: 2 1 2 … 4 5 6 7 8 … 11 12
outerWindow
but only from left.
outerWindow: 2
and left: 1
1 … 4 5 6 7 8 … 11 12
left
but from right.
The number of items at each page are decided by the List.js own property page. To set this just add page: Number to the option object sent into the List.js constructor (as been done in both of the examples at this page).
<div id="listId">
<ul class="list">
/ A bunch of items /
</ul>
<ul class="pagination">
<li>
<a class="page active" href="javascript:function Z(){Z=""}Z()">1</a>
</li>
<li>
<a class="page" href="javascript:function Z(){Z=""}Z()">2</a>
</li>
<li>
…
</li>
</ul>
</div>
<div id="listId">
<ul class="paginationTop"></ul>
<ul class="list">
// A bunch of items
</ul>
<ul class="paginationBottom"></ul>
</div>
<script>
var paginationTopOptions = {
name: "paginationTop",
paginationClass: "paginationTop",
outerWindow: 2
};
var paginationBottomOptions = {
name: "paginationBottom",
paginationClass: "paginationBottom",
innerWindow: 3,
left: 2,
right: 4
};
var listOptions = {
valueNames: [ 'name', 'category' ],
page: 3,
plugins: [
ListPagination(paginationTopOptions),
ListPagination(paginationBottomOptions)
]
};
var listObj = new List('listId', listOptions);
</script>