Class: UWA.Controls.Pager

UWA/Controls/Pager. UWA.Controls.Pager

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
Name Type Argument Default Description
className String <optional>
'uwa-pager'

Customized container classname

type Number <optional>
2

Pager display type

showPageLinks Boolean <optional>
false

Display pages links

showMoreLink Boolean <optional>
true

Display more link

pageLinks Number <optional>
5

Max number of displayed links

length Number <optional>
0

Number of entry

limit Number <optional>
10

Limit data entry per page

offset Number <optional>
0

Current offset data entry

max Number <optional>
50

Max number of page

loadNext Function <optional>
null

Callback to retrieve next data

prevLabel String <optional>
'prev'

Prev link text label

nextLabel String <optional>
'next'

Next link text label

moreLabel String <optional>
'more'

More link text label

Extends

  • UWA.Controls.Abstract

Index

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