0

Here's my situation:

I have two pages. I use this line of code to execute things when a user changes between the two pages. It works, but only when I am loading a page for the first time. If I am returning to a previous page (one that I already visited), it doesn't call this method.

$('div:jqmData(role="page")').live('pagebeforeshow',function(){ ... });

For example:

  • I visit page A; the code executes.
  • I click a link on page A to go to page B; the code executes.
  • I click a link on page B to go back to page A; the code DOES NOT execute.
  • I then refresh the page (now on page A), the code does again execute.
  • Any reason why that would happen?

    3
    • The problem has apparently been battled before stackoverflow.com/questions/7549571/… Commented Dec 6, 2011 at 2:06
    • In that case, your question is a duplicate of the other one you found. Commented Dec 6, 2011 at 2:35
    • To some extent, it has, but the other guy did not ask about returning to the same page - he said just pages in general. Commented Dec 6, 2011 at 2:55

    1 Answer 1

    1

    Here is a demonstration I made for you to show when events fire for pages in the jQuery Mobile framework (version 1.0): http://jsfiddle.net/jasper/QjtZW/1/

    When you navigate to different pages the pageshow event always fires on the page being shown as you can see in my example.

    If you are having issues with pageshow firing as it should then you probably have an error or some errors in your code that are blocking code from running. Make sure your error console is clear.

    Sign up to request clarification or add additional context in comments.

    1 Comment

    Thank you! It's pretty clear now that I'm just being an idiot about some other part of my code.

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.