Bootstrap Tooltip in Ruby on Rails
12,450
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();
});
Related videos on Youtube
Author by
Mini John
⚡️Growth Engineer ~ full stack dev ~ build fast, fix later ~ #Data Junkie ~ #Analytics Obsessed. Data & Growth @anyroad
Updated on July 12, 2022Comments
-
Mini John almost 2 years
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.)
-
vee over 10 yearsbecause you want to make sure that the DOM is fully loaded so that all referenced elements are found.
-
veeDo you have
$(document).ready(function(){...});
wrapped around$('.tag-tooltip').tooltip();
?
-
-
Tsunamis about 7 yearsIt seem to be
$(document).on('turbolinks:load', function() {/**/})
with newer turbolink versions.