Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should be able to do this automatically with just a single .live('pageinit') as shown below. </p> <pre><code>$('[data-bind="pageinit"]').live('pageinit', function (event) { alert( $('[data-role="page"]').attr('id') ); }); </code></pre> <p>This will bind a page automatically when using attribute <code>data-bind='pageinit'</code>. The alert should be showing you the ID of the page , where the must contain a <code>data-role="page"</code>. </p> <p><strong>EDIT</strong> 1 March 2013</p> <p>Seeing the other questions being voted up with code that will undoubtedly require the repetition of code I thought to update my answer with: Enter the above code before the initialization of jQuery Mobile. Every page will be bound on the first time it's loaded (so on the <code>pageinit</code> event. You'd have a setup something like this in your header:</p> <pre><code> &lt;script src="Scripts/latestJQuery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="Scripts/jQueryMobileDefaults.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="Scripts/latestJQueryMobile.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>With my code above being included in the defaults page. This would make it fire also on the page first page being loaded the very first time it gets executed. This setup would give you a much cleaner setup than a repetition of code using a different numeric identifier for each separate page. </p> <p>The event to which this can be used upon can also simply be altered. For all the events check the <a href="http://api.jquerymobile.com/category/events/" rel="nofollow">jQueryMobile documentation</a>, but for example: <code>pageinit</code> gets fired on the initialization of the page, therefore only the first time it's loaded, <code>pageshow</code> would be fired every single time the page is loaded. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload