whiteoctober/Pagerfanta — pull request #92 by leevigraham (2013-05-16 03:06:32+00:00)
Title: [RFC] Added data-pagination to view output. 

The data attribute is a json_encoded array of the following:

* url
* totalResults
* totalPages
* currentPage
* currentPageOffsetStart
* currentPageOffsetEnd

Builds on top off PR #91

Is this something that interests anyone?

This update makes it easier to add other JS hooks / events. I'm currently using it to build a perPage select box:

![image](https://f.cloud.github.com/assets/25124/510474/8096a0a8-bdd5-11e2-8388-3e75088b9d50.png)

The method in my widget looks like:

````js
_processPerPage: function (event) {

event.preventDefault();

var paginationData = this.element.find(this.options.paginationSelector).data('pagination'),
currentOffset = paginationData.currentPageOffsetStart,
perPage = $(event.target).val(),
newPage = Math.ceil(currentOffset / perPage),
uri = new URI(paginationData.url);

uri.setSearch(this.options.pageKey, newPage);
uri.setSearch(this.options.perPageKey, perPage);

$.ajax({
type: 'get',
url: uri.href(),
beforeSend: $.proxy(this._beforeSend, this),
success: $.proxy(this._success, this),
complete: $.proxy(this._complete, this)
});

},
````