Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery Accordion doesn't 'accordionize' new panels loaded via AJAX
    primarykey
    data
    text
    <p>I have to load accordion panels into one of my pages using AJAX and I'm finding that JQuery is 'accordionizing' all of the panels defined in the HTML file, but none of the panels loaded via Javascript. One other little quirk: I'm doing this on a nested accordion - the accordion within an accordion. It's accordion inception, if you will. </p> <p>I checked other Stack Overflow questions and the JQuery Forum and I found that most of them are about resizing panels after loading data. The closest question I found was <a href="https://stackoverflow.com/questions/646415/jquery-accordion-and-loading-content-through-ajax">here</a>, but it doesn't answer my question because trying to destroy and then re-accordion-ize my JS-loaded panels does not work. </p> <p><strong>This is the relevant section of my html head section:</strong> </p> <pre><code>&lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/flick/jquery-ui.css" type="text/css" /&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $(".accordion").accordion({ collapsible: true, icons: false, autoHeight: false, active: false }); }); &lt;/script&gt; </code></pre> <p><strong>This is the relevant section of my html body section:</strong> </p> <pre><code>&lt;div class="accordion"&gt; &lt;h3 id="acc1"&gt;First panel title&lt;/h3&gt; &lt;div&gt;First panel content&lt;/div&gt; &lt;h3 id="acc2"&gt;Second panel title&lt;/h3&gt; &lt;div class="accordion" id="ajaxresults-aliaslist"&gt;This is where the nested accordion goes&lt;/div&gt; &lt;h3 id="acc3"&gt;Third panel title&lt;/h3&gt; &lt;div&gt;Thirdpanel content&lt;/div&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; $("#ajaxresults-aliaslist").load("/loadaliaslist/"); &lt;/script&gt; </code></pre> <p><strong>When javascript loads "/loadaliaslist/", it received a message with the following content:</strong> </p> <pre><code>&lt;h3&gt;1st panel within a panel title&lt;/h3&gt; &lt;div&gt;1st panel within a panel content&lt;/div&gt; &lt;h3&gt;2nd panel within a panel title&lt;/h3&gt; &lt;div&gt;2nd panel within a panel content&lt;/div&gt; &lt;h3&gt;3rd panel within a panel title&lt;/h3&gt; &lt;div&gt;3rd panel within a panel content&lt;/div&gt; </code></pre> <p>I know that the content above is being passed to the div because the content appears un-accordionized when I load the page. Instead of an accordion within an accordion, I just get a bunch of boring content sitting at the first level of the dream sequence. I've got to go down a level... Wait, where was I? </p> <p><strong>Right, one more thing: I have tried two things that did not work:</strong><br> - I tried putting both the load and the accordion scripts at the bottom of the page (load first), hoping that the order would matter. (noobish? not sure...)<br> - I tried adding a script at the end to destroy and recreate the panels like so: </p> <pre><code>$("#ajaxresults-aliaslist").accordion('destroy').accordion(); </code></pre> <p>That's all. I really hope someone out there is the Leonardo DiCaprio of accordions, and can help rescue me from my predicament. Much appreciated!</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