I want to mix a dropdown and collapse menu together, but when I implent an accordion inside a dropdown-menu you can not click on the accordion toggle. The dropdown menu slides up.
Here is my code.
<ul class="nav nav-pills">
<li class="dropdown" id="menu1">
<a class="dropdown-toggle" data-toggle="dropdown" href="#menu1">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>
<a href="#">Action</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Separated link</a>
</li>
<li>
<div class="accordion" id="accordion2">
<div class="accordion-group">
<a class="accordion-toggle"
data-toggle="collapse"
data-parent="#accordion2"
href="#demo1">
aaa
</a>
<div id="demo1" class="accordion-body collapse" style="height: 0px; ">
<ul class="index-list">
......
</ul>
</div>
</div>
<div class="accordion-group">
<a class="accordion-toggle"
data-toggle="collapse"
data-parent="#accordion2"
href="#demo2">
aaa
</a>
<div id="demo2" class="accordion-body collapse">
<ul class="index-list">
......
</ul>
</div>
</div>
</div>
</li>
</ul>
</li>
...
</ul>
Here's a link to the jsFiddle: http://jsfiddle.net/DBQU7/26/
I don't think that accordions were meant to be included into dropdowns.
I think you have to trigger the accordion yourself, and avoid the extra markup that accordions would normally require. That way you can keep the dropdown style.
Here is what i came up with.
Live example : http://jsfiddle.net/Sherbrow/YqsTw/