WordPress.org

Forums

jPages pagination for WordPress
Moving to page 2 of (x) causes remaining images to display (5 posts)

  1. jgasper
    Member
    Posted 9 months ago #

    Hi,

    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);

    This then forces javascript to treat range.start and this.options.perPage as numerical values and adds them rather than trying to concatenate them together as strings.

    I hope this helps anyone else who is experiencing the same issues.

    https://wordpress.org/plugins/wp-pagination/

  2. co1inr
    Member
    Posted 9 months ago #

    Thanks, jgasper. This was a lifesaver!

  3. kishores
    Member
    Plugin Author

    Posted 9 months ago #

    Thanks, jgasper, for finding the bud. I have added the patch.

  4. jgasper
    Member
    Posted 9 months ago #

    Hi kishores,

    Thank you for applying the patch. However, your latest update has introduced two new bugs:

    1) perPage option is no longer being set for galleries in script.js.
    2) jPages_comment is throwing an "undefined" javascript error in script.js

    The fixes I implemented to correct this are as follows:

    1) On line 19 of script.js, re-add:
    perPage : jPages_count.get_default_gallery_per_page to initialize the perPage options into the jQuery script

    2) Modify line 35 of script.js to read perPage : jPages_count.get_comment_pages_count instead of perPage : jPages_comment.get_comment_pages_count

    I hope this helps anyone who is encountering issues with this new patch release.

  5. jgasper
    Member
    Posted 9 months ago #

    I should also mention that you need to make sure that line 18 of script.js reads as follows:
    containerID: id,

    Note the comma (,) after id.

    Have a good day.

Reply

You must log in to post.

About this Plugin

About this Topic