jquery - Twitter Bootstrap Collapse not toggling correctly -
i have following code:
<div id="container-collapse"> <div class="row"> <button type="button" class="span4 btn" data-toggle="collapse" data-target="#demo1" data-parent="container-collapse">button1</button> <button type="button" class="span4 btn btn-danger" data-toggle="collapse" data-target="#demo2" data-parent="container-collapse">button2</button> </div> <div class="row"> <div id="demo1" class="collapse">foo bar</div> <div id="demo2" class="collapse">herp derp</div> </div> </div>
i cannot life of me these collapse elements toggle, when 1 opens other closes. instead happens if click 1 button , other, both collapse elements remain open. thought having data-parent element help, no... grateful pointers.
what describe want called "collapse" or "accordion" in twitter.bootstrap. see jsfiddle compares solution. code accordion:
<div class="accordion" id="accordion2"> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseone"> show foo bar </a> </div> <div id="collapseone" class="accordion-body collapse in"> <div class="accordion-inner">foo bar</div> </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapsetwo">show herp derp</a> </div> <div id="collapsetwo" class="accordion-body collapse"> <div class="accordion-inner">herp derp</div> </div> </div> </div>
to use 2 buttons in 1 row:
<div class="accordion" id="accordion2"> <div class="accordion-group"> <div > <a class="accordion-toggle btn" data-toggle="collapse" data-parent="#accordion2" href="#collapseone"> show foo bar</a> <a class="accordion-toggle btn" data-toggle="collapse" data-parent="#accordion2" href="#collapsetwo">show herp derp</a> </div> <div id="collapseone" class="accordion-body collapse in"> <div class="accordion-inner">foo bar</div> </div> </div> <div class="accordion-group"> <div id="collapsetwo" class="accordion-body collapse"> <div class="accordion-inner">herp derp</div> </div> </div> </div>
Comments
Post a Comment