page calculation bug
christhomas opened this issue · 4 comments
I found in the pager the following code today
https://github.com/Mottie/tablesorter/blob/master/addons/pager/jquery.tablesorter.pager.js#L565
p.totalPages = Math.ceil( Math.min( p.totalPages, p.filteredPages ) / p.size );
surely that should be
p.totalPages = Math.ceil( Math.min( p.totalRows, p.filteredRows ) / p.size );
Cause here it appears to be dividing the number of pages by the size to obtain the number of pages, this is wrong, it should divide the number of rows by the size.
I've fixed my local copy and it appears to work, the calculation is correct, so can somebody else test this too?
I think what happens is that the calculation is wrong, but it doesnt matter in most cases because then afterwards there is another calculation which "covers" the problem and makes it correct, so you never appear to see the original error.
although of course, why it's being recalculated multiple times (obviously it is, otherwise this error would have surfaced before) I don't know, so now I'm trying to look into this.
Hi @christhomas!
Yeah you're right, it is a bug... it's within the "enable" pager code, so it is run when the pager is initialized or enabled (after disabling).
It does get corrected again, so you're right that you normally don't see this issue. Anyway, thanks! I'll fix it for the next update.
good stuff! I'll continue with my hunt :)
So far, I've only pushed these changes to the remote master... I have yet to tag and update the gh-pages. I'm going away for two weeks on Monday, so I'll try to get as many bug fixes in before then and tag the next update before I leave.