【发布时间】:2015-04-29 03:35:15
【问题描述】:
弹出框的关闭按钮有问题。第一次,我关闭弹出框很好,但是当我打开另一个并尝试关闭它时,它不再起作用了。
这里是弹出框的 JS:
$(function () {
$('[data-toggle="popover"]').popover({
"html": true,
"title": '<span class="text-info"><strong>title</strong></span>'+
'<button type="button" id="close" class="close" >× </button>',
"content": function(){
var div_id = "tmp-id-" + $.now();
return details_in_popup($(this).data('url'), div_id);
}
}).on('shown.bs.popover', function(e){
var popover = jQuery(this);
$('.close').on('click', function(e){
popover.popover('hide');
});
});
});
任何线索是什么导致了这个问题?
谢谢!
【问题讨论】:
-
将
$('.close').on('click', function(e){更改为$('body').on('click','.close', function(e){ -
我试过了,它对我不起作用......
-
但您的代码似乎正在我的 jsfiddle https://jsfiddle.net/5due81cv/... 上运行
-
我删除的唯一代码是你的
return details_in_popup($(this).data('url'), div_id);
标签: javascript jquery twitter-bootstrap popover