Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the correct way to link to the same page multiple times?
    primarykey
    data
    text
    <p>I'm trying to have a single page that can show the same type of data (lets say fruits). Then I want to load this page anywhere in my website hierarchy but each time with different parameters.</p> <p>I have my main page like the following with two links to the same page <code>show.html</code>:</p> <pre class="lang-html prettyprint-override"><code>&lt;div data-role="navbar" data-iconpos="top" data-theme="a" class="nav-ecommera"&gt; &lt;ul &gt; &lt;li&gt; &lt;a href="show.html?p=apples" data-role="button"&gt;Apples&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a href="show.html?p=oranges" data-role="button"&gt;Oranges&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>A click on each of the two buttons will create a new instance of the page <code>show.html</code> in the DOM. All of the items in show.html therefore will have duplicate ID's in the DOM.</p> <p>In my javascript I want to dynamically fill the show.html page:</p> <pre class="lang-js prettyprint-override"><code>$('div[id="show"]').live("pagebeforeshow", function(e, data) { var p = getUrlParameter("p"); show(p); }); var show = function(p) { $.ajax({ url:'http://show.com/?p='+p, success: function(data) { // Refresh 'show' page with new data // First time: It's fine. // Second time: 'show' page is duplicated in the DOM so it's messy. } }); } </code></pre> <p>Now the first time <code>show.html</code> loads everything is fine. However the second time everything in <code>show.html</code> is loaded twice and the DOM includes many duplicate ID's.</p> <p>Is there a way to remove the first page from DOM before loading the new one?</p> <p>Or:</p> <p>Is there a better approach that will do what I'm trying to achieve here?</p> <p><strong>UPDATE:</strong> I already tried removing previous instances of <code>show</code> pages when loading a new one. It works as far as showing the second page is concerned. But there is a problem when the first page needs to be shown for the second time, after being manually removed.</p> <p>I think the reason is jQuery mobile seems to think the first page is already loaded, despite the fact that we manually removed it. So it doesn't fully reload the first page when accessed again. I'm talking about this sequence of navigation: Home -> Apples -> Back to home -> Oranges -> Back to home -> Apples (Here you get a defected page). </p>
    singulars
    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