Create a default callback handler to handle pagination for local elements
| Project: | Pagination |
| Version: | 1.1 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
It looks to me like there are 2 main types of callbacks one would want to use with this.
The first is an AJAX callback where one would need to make an AJAX call back to get the new records. This would be highly user intensive and so probably not very easy to set up in a component (do-able, just not that simple).
The other callback one would use is where all the records are already available on the page, but pagination is desired for usability reasons (not necessarily performance ones).
In this case if the user is to input the record list into the pagination plugin, it should be easy to set up a default callback which will automatically paginate through the results.
The code would need to
a) determine the page id clicked (which it already does)
b) multiply that with the number of items per page to get the start of the set
c) add the number of items per page to get the end of the set
d) hide all the items
e) show the ones in the range
Here is some sample code which does just that
var itemsPerPage = 10; // configurable
paginationHandler = function(id, element, items){
var pageStart = id * itemsPerPage;
var pageEnd = pageStart + itemsPerPage;
//first hide all items
items.hide();
// show the ones that are between the page start and end
items.each(function(i){
if (i >= pageStart && i < pageEnd) {
$(this).show();
}
});
}
Basically it would be great if this could be put into the pagination plug in.
