以下是我try 的适当部分:

<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')
})

When I click, I see the request get made, but doesn't populate the popover. I don't even see HTML for the popover get added to the DOM, but that could be firebug.

有人试过这个吗?

推荐答案

请参阅我的博客文章,了解有效的解决方案:https://medium.com/cagataygurturk/load-a-bootstrap-popover-content-with-ajax-8a95cd34f6a4

First we should add a data-poload attribute to the elements you would like to add a pop over to. The content of this attribute should be the url to be loaded (absolute or relative):

<a href="#" title="blabla" data-poload="/test.php">blabla</a>

And in JavaScript, preferably in a $(document).ready();

$('*[data-poload]').hover(function() {
    var e=$(this);
    e.off('hover');
    $.get(e.data('poload'),function(d) {
        e.popover({content: d}).popover('show');
    });
});

off('hover')防止多次加载数据,popover()绑定

Please see the working JSFiddle of the example.

Jquery相关问答推荐

在学习 jQuery 之前学习 JavaScript 是个好主意吗?

使用 jQuery,当用户仍在编辑该字段时,如何将文本字段的第一个字母大写?

在 Javascript 中,字典理解或 Object `map`

jQuery Select 一个具有某个类的div,它没有另一个类

JQUERY UI Accordion 开始折叠

Jquery,清除/清空 tbody 元素的所有内容?

使用 jQuery 验证插件自定义日期格式

所有选中复选框的 jQuery 数组(按类)

获取跨域 iframe 的 DOM 内容

jQuery 和 jQuery Mobile 的区别?

从 Select 元素中获取选定的选项

如何删除/更改 JQuery UI 自动完成助手文本?

jQuery ajax 成功回调函数定义

如何重新加载/刷新 jQuery 数据表?

如何在一个元素上拥有多个数据绑定属性?

jQuery : eq() 与 get()

上传文件前验证文件扩展名

jquery $(window).width() 和 $(window).height() 在未调整视口大小时返回不同的值

如何以编程方式触发 ngClick

使用 TypeScript 设置 window.location