【发布时间】:2012-11-02 15:02:09
【问题描述】:
有人问过这个问题here,但没有给出答案或解决方案。
这些引导文件列在我的 application.js 文件的顶部:
...
//= require bootstrap-tooltip
//= require bootstrap-popover
...
我的 bootstrap_additions.js.coffee 文件包含:
$("a[rel=popover]").popover()
$(".tooltip").tooltip()
$("a[rel=tooltip]").tooltip()
在我的观点中:
<a href="#" class="btn" rel="popover" title="Title" data-content="Some content.">click</a>
当我在浏览器中输入 localhost:3000/assets/application.js 时,会出现 bootstrap-popover.js 内容。另外我发现了以下内容:
jQuery(function() {
$("a[rel=popover]").popover().on('click', preventDefault());
$(".tooltip").tooltip();
return $("a[rel=tooltip]").tooltip();
});
单击链接时,浏览器显示将移至页面顶部。当我向下滚动到链接时,会显示弹出框。除 preventDefault 外,一切正常。我错过了什么?
谢谢。
更新:为了在我的代码中保持简洁,我找到了所选答案的coffeescript version:
$("a[rel=popover]").popover().click (e) => e.preventDefault()
【问题讨论】:
标签: jquery twitter-bootstrap coffeescript