Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can check for the existence of the code you are appending before actually appending. That way on subsequent visits to the page the data will not be added:</p> <pre><code>$('#page1').live('pageshow', function () { // alert("!"); if ($(this).find('p.appended_code').length === 0) { var section1 = "&lt;p class='appended_code'&gt;some code for page 1...&lt;/p&gt;"; myClone1 = $(section1); myClone1.appendTo("#placeholder1").trigger('create'); } }); </code></pre> <p>Note that I added the 'appended_code' class to the paragraph tag that you are appending and that is the selector I used to check for the existence of appended code.</p> <p>--Update--</p> <p>You can also clean-up the code a bit if you are using naming conventions based on numbers:</p> <pre><code>var pageData = new Array(); pageData[1] = "&lt;p class='appended_class'&gt;some code for page 1...&lt;/p&gt;"; pageData[2] = "&lt;p class='appended_class'&gt;some code for page 2...&lt;/p&gt;"; $('div[id^="page"]').live('pagebeforeshow', function () { if ($(this).find('p.appended_class').length === 0) { var page_num = $(this).attr('id').replace('page', ''); $("#placeholder" + page_num).append(pageData[page_num]).trigger('create'); } }); </code></pre> <p>Note that the <code>div[id^="page"]</code> selector searches for divs with an id that starts with "page"</p> <p>Here is a jsfiddle for ya: <a href="http://jsfiddle.net/S3wE6/1/" rel="nofollow">http://jsfiddle.net/S3wE6/1/</a></p> <p>If you want the data to be appended on the initial load I would recommend making the line of code where the data is appended into a function and calling it on <code>$(document).ready();</code></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. 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