Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setMaxEntries event handler #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ custom events like this:::

The event handlers check if the new page number is inside the boundaries of the number of pages and ignore the event if it is outside.

If you filter your search results and need to update the amount of pages it renders,
call this custom event.

// Update total number of results and re-render links
$('#News-Pagination").trigger('setMaxEntries', 100);


Version history
---------------
Version 1.0
Expand Down Expand Up @@ -175,6 +182,10 @@ Version 2.2
alexhayes added an option to avoid calling the callback when the plugin is
initialized.

Version 2.3
+++++++++++
atorres757 added an event handler to update max entries and re-render links.

Future Plans
------------
* Optional links for jumping a fixed number of pages.
Expand Down
11 changes: 9 additions & 2 deletions src/jquery.pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This plugin needs at least jQuery 1.4.2
*
* @author Gabriel Birke (birke *at* d-scribe *dot* de)
* @version 2.2
* @version 2.3
* @param {int} maxentries Number of entries to paginate
* @param {Object} opts Several options (see README for documentation)
* @return {Object} jQuery Object
Expand Down Expand Up @@ -218,7 +218,14 @@
}
return false;
});

containers.bind('setMaxEntries', {maxEntries:maxentries}, function(evt, numEntries){
renderer.pc = new $.PaginationCalculator(numEntries, renderer.opts);
renderer.maxentries = numEntries;
links = renderer.getLinks(containers.data('current_page'), paginationClickHandler);
containers.empty();
links.appendTo(containers);
return false;
});
// When all initialisation is done, draw the links
links = renderer.getLinks(current_page, paginationClickHandler);
containers.empty();
Expand Down