需求:数据修改后每次需展示最新数据
方案:每次点击初始化单个popover,隐藏即销毁popover,
记录:以备不时之需
<a href="javascript:void(0);" class="RemarkInfo" index="@ID号" onclick="RemarkToggle('@ID号',this)">备注信息</a>
js
var aid="";//全局参数,传递ID
function RemarkToggle(a,obj) {
aid = a;
RemarkStart(a);//初始化popover
$(obj).popover('show');
}
function RemarkStart(a) {
//初始化popover
$(".RemarkInfo[index='"+a+"']").popover({
trigger: 'click|focus',
placement: 'left',
title: '备注信息',
html: 'true',
container: 'body',
content: RemarkMethod(a)
});
//隐藏后销毁popover
$(".RemarkInfo[index='" + a + "']").on('hidden.bs.popover', function () {
$(".RemarkInfo[index='" + a + "']").popover('destroy');
})
}
//获取popover中的内容
function RemarkMethod(a) {
var html = "";
$.ajax({
cache: false,
async: false,
type: "POST",
url: "......",
success: function (data) {
html += "<div id=\"remarkinfo\">";
html += "</div>";
}
});
return html;
}