Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Tooltip in Ruby on Rails

I'm trying to get this done for quite some time now and i can't figure out whats wrong:

My Link:

<%= link_to '#', tag, class: "tag-tooltip",
                    :data => {:toggle=>"tooltip"},
                    'data-original-title' => "Hey Whats up",
                    'data-placement' => 'right'%>

My Javascript:

$('.tag-tooltip').tooltip();

But it's not working... What am i missing ?

EDIT

If i go into my Chrome Console and insert ($('.tag-tooltip').tooltip();) it is working.

So i guess the js file is not loading ? (I checked my application.js and i'm requiring everything.)

like image 764
Mini John Avatar asked Nov 21 '13 19:11

Mini John


1 Answers

I found out the wrapping which worked:

$(document).on("ready page:change", function() {
  $('.tag-tooltip').tooltip();
});

Update:

$(document).on("turbolinks:load",function(){
  $('.tag-tooltip').tooltip();
})

With vanilla JS

document.addEventListener("turbolinks:load", function() {
  $('.tag-tooltip').tooltip();
});
like image 159
Mini John Avatar answered Nov 06 '22 09:11

Mini John