Moving to page 2 of (x) causes remaining images to display
I installed your plugin with no issues and it works great, however I believe I have discovered a bug in your jPages.js code. The issue I encountered is as follows:
- I created a gallery containing 22 images
- I set the jPages plugin to display 9 images per page in the Media settings
- I viewed the gallery, and your paging plugin indicated that there were 3 pages of images that I could view. The first page of images contained 9 images, as was as expected.
- However, when I navigated to page 2, the remaining 13 images displayed, rather than the expected 9 images that should have displayed
Upon inspecting your jPages code, I discovered that on line 341 the code that sets the range.end value was treating range.start and this.options.perPage as string values, and concatenating them rather than adding their values together. You can verify this by placing a simple alert just after line 342 that displays the value of range.start and range.end. In my case, when viewing page 1 range.end displayed as 09 (the concatenated string) rather than 9 (the value of 0 + 9). When navigating to page 2, the value of range.end in line 341 then became 099 due to your code concatenating another 9 onto the value of range.start rather than adding the values together. As a result, in line 342 where your code checks if the value of range.end is larger than the total number of remaining items in the gallery, the value of range.end was being set to 13 as 099 is greater than 13.
The fix for this is simple, and is as follows:
On line 341, change your code to range.end = range.start + (1 * this.options.perPage);
I hope this helps anyone else who is experiencing the same issues.
- The topic ‘Moving to page 2 of (x) causes remaining images to display’ is closed to new replies.