twitter-bootstrap Bootstrap 3 工具提示或弹出框不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18410887/
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
Bootstrap 3 Tooltips or Popovers doesn't work
提问by xXPhenom22Xx
I have a Django application with the front-end designed in Twitter Bootstrap 3. All of the my styling and JS is working fine including the modals, etc... But I cannot for the life of me get the tooltips of popovers to do anything....
我有一个前端在 Twitter Bootstrap 3 中设计的 Django 应用程序。我的所有样式和 JS 都运行良好,包括模态等......但我一生都无法获得弹出框的工具提示来做任何事情....
I am not throwing any errors in Firebug.
我没有在 Firebug 中抛出任何错误。
Here is the order of my includes:
这是我的包括的顺序:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap.min.js"></script>
Here is my an example call for the tooltip I took straight from the bootstrap site:
这是我直接从引导站点获取的工具提示的示例调用:
<a href="#" data-toggle="tooltip" title="first tooltip">Hover over me</a>
Anyone else have trouble with the 2 elements?
其他人对 2 个元素有问题吗?
I am fairly certain it is something dumb I've done.
我相当肯定这是我做过的蠢事。
All other JS affects provided in Bootstrap 3 like the modals & tabs are working fine...
Bootstrap 3 中提供的所有其他 JS 影响,如模态和选项卡都工作正常......
回答by steakchaser
You just need to enable the tooltip via javascript:
您只需要通过 javascript 启用工具提示:
$('some id or class that you add to the above a tag').tooltip()
回答by J.C. Gras
回答by user12195433
Opt-in functionality For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
选择加入功能 出于性能原因,工具提示和弹出窗口数据 API 是选择加入的,这意味着您必须自己初始化它们。
One way to initialize all popovers on a page would be to select them by their data-toggle attribute:
初始化页面上所有弹出框的一种方法是通过它们的 data-toggle 属性选择它们:
$(function () {
$('[data-toggle="popover"]').popover()
})

