Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Mobile Cannot stop page cache
    primarykey
    data
    text
    <p>I have a 2 page jQuery Mobile example in which I cannot stop the second page from caching it's contents from the last visit.</p> <p>Please help at <a href="http://jsfiddle.net/zRVxz/1/" rel="nofollow">http://jsfiddle.net/zRVxz/1/</a></p> <p>On page 2 enter some text into the input field and hit save which will say 'saved' and then change to page 1. On returning to page 2 the text is still in the input field. In my actual development app the save buttons saves a new record to WebSQL and this issue is running the click event more than once!!! Is it because multiple pageshow events are being applied? If so, how do I stop this happening?</p> <p>Nothing I do seems to stop page 2 from caching or stop multiple binds :o(</p> <p>The JavaScript to apply pageshow, pagehide, click events in my real world code is wrapped in a 'deviceready' event, so should only run once.</p> <pre><code>$(document).on("deviceready", function() {}); </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;div data-role="page" id="pagelist"&gt; &lt;div data-role="header"&gt; &lt;h1&gt;Header Page 1&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;p&gt;Here I would normally show a list of saved items.&lt;/p&gt; &lt;/div&gt; &lt;div data-role="footer"&gt; &lt;div data-role="navbar"&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#pagelist" data-icon="grid" class="ui-btn-active" data-transition="slide"&gt;List&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#pagenew" data-icon="plus" data-transition="slide"&gt;New&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div data-role="page" id="pagenew"&gt; &lt;div data-role="header" data-rel="back"&gt; &lt;h1&gt;Header Page 2&lt;/h1&gt; &lt;/div&gt; &lt;div data-role="content"&gt; &lt;p&gt;This is pagenew.&lt;/p&gt; &lt;p&gt; &lt;input type="text" id="name"&gt; &lt;/p&gt; &lt;button type="button" id="newsave" data-icon="plus" data-inline="true"&gt;Save&lt;/button&gt; &lt;/div&gt; &lt;div data-role="footer"&gt; &lt;div data-role="navbar"&gt; &lt;ul&gt; &lt;li&gt; &lt;a href="#pagelist" data-icon="grid" data-transition="slide"&gt;List&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="#pagenew" data-icon="plus" class="ui-btn-active" data-transition="slide"&gt;New&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p><strong>JavaScript</strong></p> <pre><code>$('#pagenew').on('pageshow', function(){ $("#newsave").click(function(){ //Save to WebSQL. alert('saved'); $.mobile.changePage("#pagelist") }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. 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