本文介绍了Ruby on Rails 中的 Bootstrap 工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试完成这件事有一段时间了,但我不知道出了什么问题:
I'm trying to get this done for quite some time now and i can't figure out whats wrong:
我的链接:
<%= link_to '#', tag, class: "tag-tooltip",
:data => {:toggle=>"tooltip"},
'data-original-title' => "Hey Whats up",
'data-placement' => 'right'%>
我的 JavaScript:
My Javascript:
$('.tag-tooltip').tooltip();
但它不起作用......我错过了什么?
But it's not working... What am i missing ?
编辑
如果我进入我的 Chrome 控制台并插入 ($('.tag-tooltip').tooltip();) 它正在工作.
If i go into my Chrome Console and insert ($('.tag-tooltip').tooltip();) it is working.
所以我猜 js 文件没有加载?(我检查了我的 application.js,我需要一切.)
So i guess the js file is not loading ? (I checked my application.js and i'm requiring everything.)
推荐答案
我发现了有效的包装:
$(document).on("ready page:change", function() {
$('.tag-tooltip').tooltip();
});
更新:
$(document).on("turbolinks:load",function(){
$('.tag-tooltip').tooltip();
})
使用原版 JS
document.addEventListener("turbolinks:load", function() {
$('.tag-tooltip').tooltip();
});
这篇关于Ruby on Rails 中的 Bootstrap 工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!