Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>ID passed in <code>data-target</code> of your <code>span.icon-minus-sign</code> has to correspond with the ID of the <code>div.colapse</code> that you want to collapse.</p> <p>Because all your <code>span.icon-minus-sign</code> are targeting all the divs outputted (because all of them have the same <code>#rUsers</code> id) it is bind to the first element it finds, and that is the first <code>div#rUsers</code>.</p> <p>To go around this, dynamically add IDs, with incrementing numbers would be the best, and add it to both data-target and id. In your case only solution I see is:</p> <p><strong>Javascript</strong></p> <pre><code>var togglerArr = []; var contentArr = []; $(".icon-minus-sign").each(function(){ togglerArr.push($(this)); }); $(".collapse").each(function(){ contentArr.push($(this)); }); for (var t = 0; t &lt; togglerArr.length; t++) { togglerArr[t][0].dataset.target = "#rUsers-" + t; } for (var c = 0; c &lt; contentArr.length; c++) { contentArr[c][0].id = "#rUsers-" + c; } </code></pre> <p>And modified html (I removed data-target and coresponding id, as we are setting those in script)</p> <pre><code>&lt;div class="accordion-group elements-by-unit" id="listView" data-bind="foreach: Types"&gt; &lt;div class="text_x-large header"&gt; &lt;span data-bind="text:Name()"&gt;&lt;/span&gt; &lt;span class="userCount"&gt;(&lt;span data-bind="text:UserCount()"&gt;&lt;/span&gt;)&lt;/span&gt; &lt;span class="icon-minus-sign" data-toggle="collapse"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="collapse in" data-bind="template: { name: 'list', foreach: $data.Users }"&gt;&lt;/div&gt; </code></pre> <p></p> <p>Please let me know if it works for you! Also make sure all .js files are called in right order.</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. 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.
 

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