【发布时间】:2013-04-22 14:53:42
【问题描述】:
我有几个按钮,每个按钮都需要一个弹出框。
我想要这样:
当我的用户单击其中一个时,我希望隐藏其他人。所以只显示一个弹出窗口
请检查并帮助我纠正这个例子:
var mycontent='<div class="btn-group"> <button class="btn">Left</button> <button class="btn">Middle</button> <button class="btn">Right</button> </div>'
$('.btn').popover({
html: true,
content:mycontent,
trigger: 'manual'
}).click(function(e) {
$(this).popover('toggle');
e.stopPropagation();
});
$('html').click(function(e) {
$('.btn').popover('hide');
});
我的html:
<ul>
<li>
<a href="#" class="btn" data-toggle="popover" data-placement="bottom" title="" >Popover</a>
</li>
<li>
<a href="#" class="btn" data-toggle="popover" data-placement="bottom" title="" >Popover</a>
</li>
</ul>
添加类似下面的代码以某种方式解决了我的问题:
$('.btn').click(function(e) {
$('.btn').popover('hide');
});
但是在每个按钮上单击两次就会出错
【问题讨论】:
-
如果我问问题的方式有问题,请在给负分之前给我留言,教我如何问下一个问题
-
为什么
trigger:'focus'不是答案?这会自动隐藏其他弹出窗口。 -
看这里,我刚刚回复Bootstrap popover normalization