Andrew
Andrew

Reputation: 3999

jQuery mobile scripts not working?

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?

    Upvotes: 0

    Views: 1613

    Answers (1)

    Jasper
    Jasper

    Reputation: 76003

    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.

    Upvotes: 1

    Related Questions