下面是我尝试的适当部分:
<a href="#" data-content="<div id='my_popover'></div>"> Click here </a>
$(".button").popover({html: true})
$(".button").click(function(){
$(this).popover('show');
$("#my_popover").load('my_stuff')
})
当我单击时,我看到请求被发出,但没有填充弹出窗口。我甚至没有看到弹出窗口的HTML被添加到DOM中,但这可能是firebug。
有人试过这个吗?
发布于 2013-01-28 18:31:08
对我来说没问题:
$('a.popup-ajax').popover({
"html": true,
"content": function(){
var div_id = "tmp-id-" + $.now();
return details_in_popup($(this).attr('href'), div_id);
}
});
function details_in_popup(link, div_id){
$.ajax({
url: link,
success: function(response){
$('#'+div_id).html(response);
}
});
return '<div id="'+ div_id +'">Loading...</div>';
}
发布于 2015-02-05 02:18:41
2015年,这是最好的答案
$('.popup-ajax').mouseenter(function() {
var i = this
$.ajax({
url: $(this).attr('data-link'),
dataType: "html",
cache:true,
success: function( data{
$(i).popover({
html:true,
placement:'left',
title:$(i).html(),
content:data
}).popover('show')
}
})
});
$('.popup-ajax').mouseout(function() {
$('.popover:visible').popover('destroy')
});
发布于 2012-03-04 05:41:32
在Gürtürk,你可以使用委托函数,并强制隐藏悬停时的弹出窗口,这是ğ代码的一个变体。
$('body').delegate('.withajaxpopover','hover',function(event){
if (event.type === 'mouseenter') {
var el=$(this);
$.get(el.attr('data-load'),function(d){
el.unbind('hover').popover({content: d}).popover('show');
});
} else {
$(this).popover('hide');
}
});
https://stackoverflow.com/questions/8130069
复制相似问题