我正在尝试填充 popover
动态地通过
JavaScript
$("[data-bind='popover']").popover({
trigger: 'hover',
html: true,
content: function(){
return "<img src="+$(this).data('content')+" />";
};
});
HTML
<a href="myreference.html" data-bind="popover" data-content="mylinktoimage">Brick</a>
问题是如果我设置 width
和 height
在img
里面tag
里面js
, popover
出现。如果我不设置它们,首先是 anchor <a>
pointer cursor
“振动”和 popover
未显示。
这会是什么问题?
最佳答案
你确定上面的代码真的有效吗?甚至不能让弹出窗口工作,例如
..
return "<img src="+$(this).data('content')+" />;
});
??认为那是你的问题。
<a href="myreference.html" data-bind="popover" data-content="flower.jpg">Brick</a>
更新,也适用于外部在线图片
<a href="myreference.html" data-bind="popover" data-content="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Flower_poster_2.jpg/451px-Flower_poster_2.jpg">Brick</a>
和
$("[data-bind='popover']").popover({
trigger: 'hover',
html: true,
content: function(){
return '<img src="'+$(this).data('content')+'">';
}
});
产生:
$("[data-bind='popover']").popover({
trigger: 'hover',
html: true,
content: function(){
return '<img src="'+$(this).data('content')+'" width="50">';
}
});
产生
没有“振动”等
关于jquery - bootstrap 2.3.2 popover html 内容问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18853263/