Options that can be passed to the second argument of the Pagination
class’s
constructor:
new Pagination(el, {
active: 10,
activeClass: "active",
…
});
- Default
-
0
- Type
-
Number
Zero-based index of the currently-selected link.
Setting this property will trigger the [onChange] callback (if specified).
Should the callback return an explicit value of false
, the assignment is
aborted, and no change will be made to the property.
- Default
-
…
- Type
-
String | Function | Node
The blueprint for generating truncation indicators.
See linkTemplate
for details on how blueprints are handled.
- Default
-
1
- Type
-
Number
Total number of pages that can be traversed using this instance.
While the default value is 1 page, you’ll obviously want to set this to a more relevant/useful value.
- Default
-
undefined
- Type
-
HTMLElement | Function | String
The blueprint used to generate new page links. How it’s used depends on type:
Element: If given a reference to an element, it’s detached from the DOM and deep-cloned whenever a new link is created. The deepest node inside the element is used for displaying the link’s index:
<li class="template">
<a href="#">
»
<span> %REPLACED% </span>
</a>
</li>
Function:
A callback can be used to return a new HTMLElement.
Functions are called with two parameters: the page link’s index, and a reference
to the relevant Pagination
instance.
String: Strings are parsed as HTML blocks. As with element references, the deepest node inside the parsed block is used for displaying the link’s index.
- Default
-
undefined
- Type
-
Function
Callback triggered whenever the instance’s active property is changed. The callback is passed two arguments: the new value about to be set, and the previous value.
If the function returns false
, the assignment is cancelled.