new UWA.Controls.Pager(options)
Display a Pager with next and previous links.
Available Events
Event | Description |
---|---|
onOffsetChange |
Triggered on Offset Change |
onPageClick |
Triggered on page link clicked |
onPrevClick |
Triggered on prev link clicked |
onNextClick |
Triggered on next link clicked |
onMoreClick |
Triggered on more link clicked |
onLoadingStart |
Triggered on data load start |
onLoadingEnd |
ITriggered on data load end |
loadNext option:
When the pager get to the end of the data (offset == length), it will call the loadNext function to retrieve more data. The function is called with two arguments:
- The current length
- A function to call with the new data length, to allow asynchronous data retrieval. Make sure to call it exactly one time, no matter what.
See example below:
var data = [];
var pager = new UWA.Controls.Pager({
limit: 5,
offset: 0,
length: data.length,
events: {
onOffsetChange: onPagerOffsetChange.bind(this),
onMoreClick: onPagerMoreClick.bind(this)
}
});
var data = [];
function loadNext(index, next) {
UWA.Data.request('http://example.org/api.php?json', {
type: 'json',
data: {
from: index
},
onComplete: function (result) {
data = data.concat(result);
next(data.length);
}
});
}
var pager = new UWA.Controls.Pager({
limit: 5,
offset: 0,
max: 100,
length: data.length,
loadNext: loadNext
});
Parameters
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Options hash or a option/value pair. Properties
|
Extends
- UWA.Controls.Abstract
Index
Members
Methods
Members
-
<protected> defaultOptions
-
Properties:
Name Type Description defaultOptions
Object The default controls options.
Methods
-
setLength(length) → {Object}
-
Update the pager length.
Parameters
Name Type Description length
Object The new pager length
Returns
The current UWA.Controls.Pager instance.
- Type
- Object
-
setOffset(length) → {Object}
-
Update the pager offset.
Parameters
Name Type Description length
Object The new pager offset
Returns
The current UWA.Controls.Pager instance.
- Type
- Object
-
setLimit(length) → {Object}
-
Update the pager limit.
Parameters
Name Type Description length
Object The new pager limit
Returns
The current UWA.Controls.Pager instance.
- Type
- Object
-
getPageOffset() → {Number}
-
Get the current page offset.
Returns
The current page offset.
- Type
- Number
-
getPages() → {Number}
-
Get the current number of pages of the pager.
Returns
The current number of pages.
- Type
- Number
-
isLastPage() → {Boolean}
-
Check is the current page is the last one.
Returns
true
if the current page is the last one.- Type
- Boolean
-
buildSkeleton()
-
Build main pager elements
-
onRefresh()
-
Update main pager elements