Treehouse: Grow your CSS skills. Land your dream job.

javascript help – difficulty level = high

  • # June 22, 2012 at 11:18 pm

    Here is my issue. I have a gallery on this page

    at the bottom of the page, there is a pagination. If you click on the pagination to change to another page, it does work. if you then choose a different category in the sortable, it will change categories but stay on the currently selected page. So if I choose category “Games” and then switch to page two of that category, then choose category “Science”, you will see that the currently selected page still shows as page two. I want to try to get the pagination script to switch back to page one when a new category is chosen. What do you think? Can you help?

    # June 23, 2012 at 5:19 pm

    The trick is to add something in your click function of the “filters”, so you trigger an action on the pagination there.
    What I rapidly found working :
    $('.simplePageNav1 a').click();
    to trigger a click on page 1
    Seems to work fine:
    hoping this help
    you’re welcome

    # June 23, 2012 at 9:01 pm

    I tried your fix and it works. Thank you very much.

    Can you explain why it works?

    # July 1, 2012 at 3:29 pm

    I think you have two different functions: one for the numbered pagination and one for the filters. Your pagination one is first, and there is no test to check the filters.

    With the .click() jQuery method you can emulate the “click event” on the “page one” of the pagination.
    Done at the right time in your function for the filters., it will send a message to your pagination function.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.