Ruby on Rails中的Bootstrap工具提示 [英] Bootstrap Tooltip in Ruby on Rails

查看:52
本文介绍了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.)

推荐答案

我发现了有效的包装方法:

I found out the wrapping which worked:

$(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工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆