Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery mobile: new content on internal page transition
    primarykey
    data
    text
    <p>I'm trying to write a simple app that has several internal pages. From <code>#page2</code> I want to return to <code>#page1</code> AND reload it so that content generated by javascript will refresh.</p> <pre><code>&lt;body&gt; &lt;div id="page1" data-role="page"&gt; &lt;script type="text/javascript"&gt; //Javascript spits out something new every time &lt;/script&gt; &lt;/div&gt; &lt;div id="page2" data-role="page"&gt; &lt;a id="page1button" href="page1" data-role="button"&gt;go to page1&lt;/a&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>The only way I can make this work is by adding <code>rel="external"</code> to <code>#page1button</code>. The content refreshes BUT there is an abrupt page reload that isn't sexy. Is there a way to achieve the same results, but still use jqm's transitions?</p> <p>I know this is a popular question and I've done a lot of research, including <a href="http://jquerymobile.com/demos/1.0/docs/pages/page-scripting.html" rel="nofollow">the jqm documentation on changing pages</a>, but nothing I've tried seems to work. <code>$.mobile.changePage()</code> appears to have an option: <code>reloadPage:true</code> which claims to do exactly what I need, but it doesn't work. I've even tried <code>$.mobile.loadPage()</code> BEFORE <code>.changePage()</code> and still no luck. Help!</p> <h3>UPDATE:</h3> <p>I'm pretty sure this isn't a caching issue because here's what my page element looks like and it STILL shows the same *$#%&amp;ing thing every time I return to the page:</p> <pre><code>&lt;div id="page2" data-role="page" data-cache="never" data-dom-cache="false"&gt; ... </code></pre> <p>I'm thinking that the javascript block only gets called once when the html page loads, rather than each time I return to that div using jqm. Maybe the way to solve this is by figuring out a way to force that block of code to run again. Any ideas?</p> <h3>UPDATE:</h3> <p>Good news: I found the page which speaks to this EXACT issue: <a href="http://jquerymobile.com/test/docs/pages/page-scripting.html" rel="nofollow">http://jquerymobile.com/test/docs/pages/page-scripting.html</a></p> <p>Bad news: What it claims will work...</p> <p><code>$( document ).delegate("#page1", "pageinit", function() { alert('RE-RUN JAVASCRIPT'); });</code></p> <p>...DOESN'T!! I placed this function in the head of my html file and it only runs once.</p> <h3>UPDATE:</h3> <p>Still struggling with this. I put some code up here: <a href="http://dl.dropbox.com/u/28286159/index.html" rel="nofollow">http://dl.dropbox.com/u/28286159/index.html</a></p> <p>To keep things simple, I just did two pages with one of them containing a <code>&lt;script&gt;</code> that prints out: <code>document.write(Math.random());</code></p> <p>You you'll see that the number doesn't change.</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.
 

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