Twitter bootstrap 引导弹出关闭按钮出现问题
请看一下,并让我知道为什么在通过添加的关闭按钮关闭popover后,我无法在第一次单击时弹出popoverTwitter bootstrap 引导弹出关闭按钮出现问题,twitter-bootstrap,twitter-bootstrap-3,Twitter Bootstrap,Twitter Bootstrap 3,请看一下,并让我知道为什么在通过添加的关闭按钮关闭popover后,我无法在第一次单击时弹出popover $(document).ready(function(){ $('[data-toggle="popover"]').popover({ placement : 'top', html : true, title : 'User Info <a href="#" class="close" data-dismiss="alert
$(document).ready(function(){
$('[data-toggle="popover"]').popover({
placement : 'top',
html : true,
title : 'User Info <a href="#" class="close" data-dismiss="alert">×</a>',
content : '<div class="media"><a href="#" class="pull-left"><img src="../images/avatar-tiny.jpg" class="media-object" alt="Sample Image"></a><div class="media-body"><h4 class="media-heading">Jhon Carter</h4><p>Excellent Bootstrap popover! I really love it.</p></div></div>'
});
$(document).on("click", ".popover .close" , function(){
$(this).parents(".popover").popover('hide');
});
});
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({
位置:'顶部',
是的,
标题:“用户信息”,
内容:'Jhon Carter非常棒的Bootstrap popover!我真的很喜欢它。'
});
$(document).on(“click”,“.popover.close”,函数(){
$(this.parents(“.popover”).popover('hide');
});
});
正如你所看到的,每次点击
Click Me时,弹出窗口都是可用的,不知道为什么会发生这种情况-这似乎是一个bug。但是,当用户单击“关闭”按钮时,只需触发popover按钮的单击事件即可解决此问题:
$(document).ready(function(){
$('[data-toggle="popover"]').popover({
placement : 'top',
html : true,
title : 'User Info <a href="#" class="close" data-dismiss="alert">×</a>',
content : '<div class="media"><a href="#" class="pull-left"><img src="../images/avatar-tiny.jpg" class="media-object" alt="Sample Image"></a><div class="media-body"><h4 class="media-heading">Jhon Carter</h4><p>Excellent Bootstrap popover! I really love it.</p></div></div>'
}).on('shown.bs.popover', function() {
var popup = $(this);
$(this).parent().find("div.popover .close").click(function() {
popup.click();
});
});
});
$(文档).ready(函数(){
$('[data toggle=“popover”]')。popover({
位置:'顶部',
是的,
标题:“用户信息”,
内容:'Jhon Carter非常棒的Bootstrap popover!我真的很喜欢它。'
}).on('show.bs.popover',function(){
var popup=$(这个);
$(this.parent().find(“div.popover.close”)。单击(函数(){
弹出。单击();
});
});
});