1
我想通过AJAX填充通知弹出窗口。我在同一页上有两个弹出窗口。其他popover的内容由PHP填充。该AJAX工作正常。PHP Ajax Bootrstrap弹出式广告位置问题
问题是通知弹出窗口显示在其他弹窗的位置,而不是我点击的地方。只有从AJAX获取数据内容时才会出现此问题。从PHP或某些字符串生成的内容按预期工作。
下面是对AJAX酥料饼代码:
$(document).ready(function() {
$('#npop').popover({
template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content" style="padding:0px;overflow-y:auto;max-height:450px;"><p></p></div></div></div>',
html: true,
placement: 'bottom',
title: 'Notifications',
content: function(){
var div_id = "tmp-id-" + $.now();
return details_in_popup(div_id);
}
});
});
function details_in_popup(div_id){
$.ajax({
url: "<?php echo base_url('pull_notify'); ?>",
success: function(response){
$('#'+div_id).html(response);
}
});
return '<div id="'+ div_id +'">Loading...</div>';
}
这是我的HTML元素:
<div class="notification-icon navbar-brand">
<span>
<a style="color: #008ae6;font-size:25px;" id="npop" class="glyphicon glyphicon-bell" role="button" data-toggle="popover" ></a></span>
<span id="bad" class="badge badge-notify"></span>
</div>