Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Any new enhancement to the DOM should be done before the page initializes. But by default JQM automatically initializes the page once the page is load in browser. </p> <p>Hence first you need to set autoInitializePage property to false and then call initializePage() method after the new page and links are add to the document. Hope this helps.</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt; &lt;script src="http://code.jquery.com/jquery-1.8.2.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).bind("mobileinit", function(){ $.mobile.autoInitializePage = false; }); &lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { //add a link. $("#page1 div[data-role='content']").append('&lt;a href="#page2"&gt;Next Page&lt;/a&gt;'); //add a page. $('body').append(' &lt;div data-role="page" id="page2" data-title="next page"&gt;&lt;header data-role="header" class="header"&gt; &lt;h5&gt;Page 2&lt;/h5&gt;&lt;/header&gt;&lt;div data-role="content"&gt;&lt;h3&gt;Good Morning...&lt;/h3&gt;&lt;a href="#page1"&gt;Back&lt;/a&gt;&lt;/div&gt;&lt;footer data-role="footer" data-position="fixed"&gt;&lt;h5&gt;&amp;copy; All rights reserved&lt;/h5&gt;&lt;/footer&gt;&lt;/div&gt;'); }); window.onload = function() { $.mobile.initializePage(); }; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div data-role="page" id="page1"&gt; &lt;header data-role="header" class="header"&gt; &lt;h5&gt;jQuery Mobile&lt;/h5&gt; &lt;/header&gt; &lt;div data-role="content"&gt; &lt;form method="get" action="" data-transition="slideup"&gt; &lt;label for="email"&gt;Email:&lt;/label&gt; &lt;input type="email" name="email" id="email" value=""/&gt; &lt;/form&gt; &lt;/div&gt; &lt;footer data-role="footer" data-position="fixed"&gt;&lt;h5&gt;&amp;copy; All rights reserved&lt;/h5&gt;&lt;/footer&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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