我在Rails 4.0上使用Bootstrap 2.3.2的下拉菜单,我试图在下拉菜单中点击一个按钮后保持下拉菜单打开(所以我只想在我重新点击下拉菜单时关闭它 - 切换元素)
我尝试按照此处https://stackoverflow.com/questions/14544741/angularjs-directive-to-stoppropagation#=的解决方案无效...以下是我尝试在html.erb上执行的操作。请告诉我我做错了什么,或者如果你有更好的工作解决方案,请告诉我。任何提示都会非常感谢,提前谢谢!
<div class="dropdown">
<a **ng-click="$event.stopPropagation();"** class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<div>
<button type="button" class="btn btn-primary" data-toggle="button">
</di>
</ul>
</div>
答案 0 :(得分:0)
不应该是应用于可点击元素本身的停止传播吗?
<div class="dropdown">
<a class="dropdown-toggle" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="/page.html">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<div ng-click="$event.stopPropagation();">
<button type="button" class="btn btn-primary" data-toggle="button">
</di>
</ul>
</div>