Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Set an option without triggering the paged event #20

Merged
merged 1 commit into from
Jul 26, 2013
Merged
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
45 changes: 29 additions & 16 deletions js/jquery.jqpagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

};

base.setPage = function (page) {
base.setPage = function (page, prevent_paged) {

// return current_page value if getting instead of setting
if (page === undefined) {
Expand Down Expand Up @@ -190,11 +190,11 @@
base.$input.data('current-page', page);

// update the input element
base.updateInput();
base.updateInput( prevent_paged );

};

base.setMaxPage = function (max_page) {
base.setMaxPage = function (max_page, prevent_paged) {

// return the max_page value if getting instead of setting
if (max_page === undefined) {
Expand All @@ -218,7 +218,7 @@
base.$input.data('max-page', max_page);

// update the input element
base.updateInput();
base.updateInput( prevent_paged );

};

Expand Down Expand Up @@ -308,21 +308,34 @@

case 'option':

// call the appropriate function for the desired key (read: option)
switch (key.toLowerCase()) {

case 'current_page':
return base.setPage(value);

case 'max_page':
return base.setMaxPage(value);

// set default object to trigger the paged event (legacy opperation)
var options = {'trigger': true},
result = false;

// if the key passed in is an object
if($.isPlainObject(key) && !value){
$.extend(options, key)
}
else{ // make the key value pair part of the default object
options[key] = value;
}

// if we haven't already returned yet we must not be able to access the desired option
console.error('jqPagination: cannot get / set option ' + key);
return false;
var prevent_paged = (options.trigger === false);

// if max_page property is set call setMaxPage
if(options.max_page !== undefined){
result = base.setMaxPage(options.max_page, prevent_paged);
}

// if set_page property is set call setPage
if(options.set_page !== undefined){
result = base.setPage(options.set_page, prevent_paged);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set_page should actually read current_page
oops

lines 331 and 332


// if we've not got a result fire an error and return false
if( result === false ) console.error('jqPagination: cannot get / set option ' + key);
return result;

break;

case 'destroy':
Expand Down