Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Dialog - dialog fields added multiple times to the DOM
    primarykey
    data
    text
    <p>I'm using the Jquery UI to display tabs. In one of the tabs, I have a dialog box. If I navigate to that tab, open the dialog, close it, navigate off the tab then back again and open the dialog, I end up with multiple and duplicate HTML elements in the DOM. </p> <p>In other words...</p> <p>I've got my main page setup with tabs:</p> <pre><code>&lt;div id="groupTabs" style="width:600px; height:600px; display:none"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="tab1.aspx"&gt;&lt;span&gt;Info&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="tab2.aspx"&gt;&lt;span&gt;Associations&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Tab #2 contains a dialog box:</p> <pre><code>&lt;div id="dgEvent"&gt; &lt;input id="someId"&gt; &lt;/div&gt; ... $("#dgEvent").dialog(); </code></pre> <p>I've found that if I open the dialog, navigate away (to another tab) and back again, the next time I open up the dialog I'll end up with duplicate elements both named "someId" in my DOM. This causes problems because when I try to grab the value from someID (i.e, $("#someID").val(), I end up getting the value from the first instance of the dialog.)</p> <p>Is there a fix to make sure that the fields are removed when the dialog is closed? Or better yet, that they are removed properly when navigating to another tab?</p> <p><strong>EDIT</strong></p> <p>In the end, I believe the problem is related to the use of Tabs and Dialog together. Any field I have on the form that is outside the dialog gets removed from the DOM when I navigate off the tab. However, anything that was in the dialog remains in the DOM after I navigate away. Thus, when I navigate back, I end up with duplicates.</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.
 

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