我正在尝试将带有一些表单元素和下拉类别选择的面板放入bootstrap中的可折叠导航栏中。目前我有
<div class="collapse navbar-collapse" style="z-index:5;">
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><img class="headerToolbarIcon2" src="img/configuration.png"> Configuration<b class="caret"></b></a>
<form class="dropdown-menu" style="width:425%; padding-top:1px;">
<li>
<div class="container" id="configurationPanel" style="height:140px;">
<div class="panel-body panel-default" style="float:left;">
<p><strong> Article <br/> Properties:</strong></p>
</div>
<div class="panel-body panel-default" style="float:left; margin-left:20px;" >
<p style="border-bottom:1px solid black;"><strong>Category</strong></p>
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data>
Personal <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Weather</a></li>
<li><a href="#">Military</a></li>
<li><a href="#">International</a></li>
<li class="divider"></li>
<li><a href="#">Uncategorized</a></li>
</ul>
</div>
</div>
</div>
</li>
</form>
</li>
</ul>
</div>
</div>
我在面板上停止了事件传播,单选按钮效果很好,但每当我点击“个人”按钮从类别中选择时,面板就会关闭。我确定它与父下拉列表的数据目标有关,但我不知道如何解决这个问题。
答案 0 :(得分:0)
Bootstrap 3.0.3无法显示2个带有data-toggle =“dropdown”的下拉菜单类,因为首先单击show class =“dropdown-menu”,然后再单击隐藏first class =“dropdown-menu”并显示第二。这是你的问题。
试试这个解决方案:
<div class="collapse navbar-collapse" style="z-index:5;">
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a id="dp1" class="dropdown-toggle" data-toggle="dropdown" href="#" ><img class="headerToolbarIcon2" src="vbnet.PNG" width="20px" height="20px"> Configuration<b class="caret"></b></a>
<form class="dropdown-menu" style="width:425%; padding-top:1px;">
<li>
<div class="container" id="configurationPanel" style="height:140px;">
<div class="panel-body panel-default" style="float:left;">
<p><strong> Article <br/> Properties:</strong></p>
</div>
<div class="panel-body panel-default" style="float:left; margin-left:20px;" >
<p style="border-bottom:1px solid black;"><strong>Category</strong></p>
<div class="btn-group">
<button id="dp2" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Personal <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Weather</a></li>
<li><a href="#">Military</a></li>
<li><a href="#">International</a></li>
<li class="divider"></li>
<li><a href="#">Uncategorized</a></li>
</ul>
</div>
</div>
</div>
</li>
</form>
</li>
</ul>
</div>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="bootstrap.min.js"></script>
<script>
$(function(){
$("#dp2").click(function(){
$("#dp1").attr("data-toggle","");
$("#dp1").one("click",function(){
$("#dp1").attr("data-toggle","dropdown");
});
});
});
</script>