Skip to content

New Callback #24

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

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
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ load_first_page
initialized. If you load your content with AJAX and already show content
whey you initialize the pagination, you should set this to false.

before_select_page_callback
Similar to callback, but this fires before the pagination links render.
A return of false will prevent the page switch from occurring and will
stop the event's propagation.

Triggering pagination with custom events
----------------------------------------
There may be use cases where you want to change the pagination from your own
Expand Down
6 changes: 5 additions & 1 deletion src/jquery.pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@
renderer:"defaultRenderer",
show_if_single_page:false,
load_first_page:true,
callback:function(){return false;}
callback:function(){return false;},
before_select_page_callback:function(){return true;}
},opts||{});

var containers = this,
Expand All @@ -171,6 +172,9 @@
* the callback function.
*/
function selectPage(new_current_page) {
if (!opts.before_select_page_callback(new_current_page, containers)) {
return false;
}
// update the link display of a all containers
containers.data('current_page', new_current_page);
links = renderer.getLinks(new_current_page, paginationClickHandler);
Expand Down