diff --git a/README.rst b/README.rst index a8cdb5d..ec8d170 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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. diff --git a/src/jquery.pagination.js b/src/jquery.pagination.js index 7cf5aed..1a7ae38 100644 --- a/src/jquery.pagination.js +++ b/src/jquery.pagination.js @@ -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 @@ -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();