timhc22
timhc22

Reputation: 7451

jqpagination 'get' current_page

In regards to this pagination plugin: http://beneverard.github.io/jqPagination

$('.pagination').jqPagination('option', 'current_page')

Should 'get' the current page. However it returns the value 'false'

$('.pagination').jqPagination('option', 'current_page', 4)

Should 'set' the current page to 4. And it does.

Am I doing something wrong here or is there a bug in the 'getter' code?

Upvotes: 0

Views: 1123

Answers (1)

timhc22
timhc22

Reputation: 7451

Found the answer on the issues list on github: https://github.com/beneverard/jqPagination/issues/26

hopefully will be dealt with by the next version:

BOAndrew commented 4 months ago Hi Ben, First of all thanks for your contribution. I also used your pagination plugin and encountered this problem with getting values. The solution is simple:

Just add the following lines after line 310 (function 'callMethod', switch, case 'option')

base.callMethod = function (method, key, value) {
    switch (method.toLowerCase()) {
        case 'option':  // line 310
            //added code
            if (value === undefined) {
                return base.options[key];
            }
            // end of added code

This does not check if the requested value is actually part of the 'options' objects so it can return undefined but in the same time the code remains flexible (in case you want to add more options later).

Upvotes: 0

Related Questions