Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


various page events do not fire on first load. #508

mrubinsk opened this Issue · 6 comments

2 participants


When loading a file for the first time, the various page events do not fire. Example, the following structure:

 <div data-role="page" id="pageOne">
     <div data-role="header"><h3>Page One</h3></div>
     <div data-role="content" class="ui-body"><a href="#pageTwo">Page One</a></div>
 <div data-role="page" id="pageTwo">
     <div data-role="header"><h3>Page Two</h3></div>
     <div data-role="content" class="ui-body">Page Two</div>

and the following javascript:

<script type="text/javascript">
 $(function() {
   $('#pageOne').live('pageshow', function() { alert('showing pageone'); });
   $('#pageTwo').live('pageshow', function() { alert('showing pagetwo'); });

Neither of the pageshow events will fire (neither pageOne on first load, or pageTwo, if the url includes the #pageTwo hash). The $.mobile.currentPage alert fires, but shows undefined. Navigating after the page is loaded works as expected.


Did you place your script between jquery and jquery mobile? These events must be bound before jQuery mobile executes. I just tested on my end and it seems to be working as expected...


Nope. The script is placed after both jquery and jquery mobile in the head. It also occurs if I place the script at the end of the body as well.

I put my test script up at:

Expected behavior:
pagebeforecreate, beforepageshow, pageshow events should fire during initial page load, and beforepageshow, pageshow events should fire at appropriate times during subsequent navigation.

Demonstrated behavior:
No events at all are fired during initial page load, and only the pageshow events are fired during subsequent navigation. The page initialization events are never fired.


Oh, wait, all of these have to be bound before jquery mobile is loaded?


Ok, I guess that makes sense now that I think about it. Still, how about updating the documentation to make this more obvious?

Thanks for the help.


The third paragraph on this page explains it, but please send us a pull request if you figure out a better way:






This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.