I've been scratching my head on this for the past 2 hours. I have an accordion with two panels. I want the first panel to be expanded by default. When the collapsed panel's header is clicked, I want that panel to expand and the other to collapse. It only works in certain situations for the second panel.
Here is a JSFiddle.
Here is my markup:
<div id="proposalAccordian" class="panel-group">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#proposalAccordian" href="#collapseContact">Contact</a>
</h4>
</div>
<div id="collapseContact" class="panel-collapse collapse in">
<div class="panel-body">
@Html.Partial("_ContactPanel")
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#proposalAccordion" href="#collapseProposal">Proposal</a>
</h4>
</div>
<div id="collapseProposal" class="panel-collapse collapse">
<div class="panel-body">
@Html.Partial("_ProposalPanel")
</div>
</div>
</div>
</div>
I'm using Bootstrap v3.1.1 and jQuery v1.10.4.
You need to add data-parent="#proposalAccordian"
<a data-toggle="collapse" data-parent="#proposalAccordian" href="#collapseProposal">Proposal</a>
See fiddle: http://jsfiddle.net/nicos/JKqGc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With