twitter-bootstrap Bootstrap 3 弹出框可以使用外部 div 来显示内容吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23273025/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can Bootstrap 3 popovers use an external div for content?
提问by Steve
All of the examples here http://getbootstrap.com/javascript/#popoversuse inline content for the popovers with the data-contentattribute.
http://getbootstrap.com/javascript/#popovers 中的所有示例都使用具有data-content属性的弹出窗口的内联内容。
What I'd like to do is set up a hidden divon my page with the content, and target that from the popover trigger, like:
我想要做的是div在我的页面上设置一个隐藏的内容,并从弹出窗口触发器中定位,例如:
<div id="myPopoverContent">
...stuff...
</div>
and then
接着
<a ng-href="" data-toggle="popover"><span class="badge">12</span> You have 12 messages.</a>
as the trigger. But how to trigger?
作为触发器。但是怎么触发呢?
回答by Raphael Schweikert
Use the contentoption of the popoverfunction to pass the content:
使用函数的content选项popover来传递内容:
{
content: $('#myPopoverContent').text()
}
To be able to use HTML content, use:
为了能够使用 HTML 内容,请使用:
{
content: $('#myPopoverContent').html(),
html: true
}
I've prepared a working examplefor you.
我已经为你准备了一个工作示例。

