twitter-bootstrap-3listgrid

Bootrstap 3 - list group with accordion functionality


 <div class="list-group" id="menu">
 <a href="#" class="list-group-item" data-toggle="collapse" data-target="#sm" data-parent="#menu">MESSAGES <span class="label label-info">5</span> <span class="glyphicon glyphicon-envelope pull-right"></span></a>
 <div id="sm" class="sublinks collapse">
  <a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> inbox</a>
  <a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> sent</a>
 </div>
 <a href="#" class="list-group-item" data-toggle="collapse" data-target="#sl" data-parent="#menu">TASKS <span class="glyphicon glyphicon-tag pull-right"></span></a>
 <div id="sl" class="sublinks collapse">
  <a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> saved tasks</a>
  <a class="list-group-item small"><span class="glyphicon glyphicon-chevron-right"></span> add new task</a>
 </div>
 <a href="#" class="list-group-item">ANOTHER LINK ...<span class="glyphicon glyphicon-stats pull-right"></span></a>
</div>

In spite of both <a> got data-parent="#menu", none of them appearing triggers other to hide. How to update this code to hide one sublinks as other are visible?


Solution

  • The #menu must be a parent of the list-group, and the list-group needs to have the panel class.

    http://www.bootply.com/tGF9MEGbLM