Skip to content
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

Pager widget - inconsistency between pageSet and p.page #1516

Open
iustin opened this issue Feb 23, 2018 · 4 comments
Open

Pager widget - inconsistency between pageSet and p.page #1516

iustin opened this issue Feb 23, 2018 · 4 comments

Comments

@iustin
Copy link

iustin commented Feb 23, 2018

Hello,

I think the docs are incorrect regarding p.page (the widget). It says that both it, and the pageSet event, use a one-base index. While that is true for the pageSet, it looks like p.page is zero-based. You can see this inconsistency here:

p.page = ( parseInt( num, 10 ) || 1 ) - 1;

(num being the argument to pageSet).

I think it'd be best that zero-based is always used, but if that's not possible (backwards compat), then at least the docs for p.page should be updated.

@Mottie
Copy link
Owner

Mottie commented Feb 24, 2018

Hi @iustin!

Yes, the p.page variable is stored as a zero-based index. All internal functions use a zero-based index. The pager methods (pageAndSize, pageSet and pageSize) all use a one-based index as this was expected to be used along with the user interface – which shows a one-based index to the user.

As a developer, you can change the table.config.pager.page and table.config.pager.size values directly using a zero-based index, then call the $.tablesorter.pager.moveToPage(config, config.pager) function.

Either way, I think it's too late to change this behavior now since it would not be backwards compatible, and I don't plan on creating a major revision with tablesorter. I will make this behavior consistent once I get around to working on Abelt again.

@iustin
Copy link
Author

iustin commented Feb 25, 2018

Sounds good to not change the code - but what do you think about fixing the docs? I couldn't find exactly where in the repository are the doc pages to send a pull request, sorry. Basically just fixing the wording on p.page (which incorrectly states one-based indexing).

@Mottie
Copy link
Owner

Mottie commented Feb 25, 2018

Oops! Ok, I'll get that fixed.

@iustin
Copy link
Author

iustin commented Feb 25, 2018

Ah, so the main page is simply index.html, wondering why I couldn't find that wording (I blame github search). Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants