Created
April 4, 2011 15:52
-
-
Save davemo/901869 to your computer and use it in GitHub Desktop.
A way to short circuit the pagination action to add a custom hook to a YUI DataTable that uses a YUI Paginator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cache the old hook so you can call it later | |
var _oldDoBeforePaginatorChange = yuiTableInstance.doBeforePaginatorChange; | |
// reassign the doBeforePaginatorChange | |
// proposed state is a default arg passed by the calling function in the YUI stack. | |
yuiTableInstance.doBeforePaginatorChange = function(proposedState) { | |
if(!someCustomValidation) { | |
// returning false is important as the default doBeforePaginatorChange simply returns true. | |
// this will shortcircuit the paginator so it doesn't change pages. | |
return false; | |
} | |
// if your validation passes, just pass through the call to the original function | |
return _oldDoBeforePaginatorChange.call(yuiTableInstance, proposedState); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment