I am new to Bootstrap and I\'m having trouble getting the popover and tooltip features to work. I had no problem with the drop downs and models but I seem to be missing some
I use this on all my pages to enable tooltip
$(function () { $("[data-toggle='tooltip']").tooltip(); });
If you're using Rails and ActiveAdmin, this is going to be your problem: https://github.com/seyhunak/twitter-bootstrap-rails/issues/450 Basically, a conflict with active_admin.js
This is the solution: https://stackoverflow.com/a/11745446/264084 (Karen's answer) tldr: Move active_admin assets into the "vendor" directory.
Turns out that Evan Larsen has the best answer. Please upvote his answer (and/or select it as the correct answer) - it's brilliant.
Working jsFiddle here
Using Evan's trick, you can instantiate all tooltips with one line of code:
$('[data-toggle="tooltip"]').tooltip({'placement': 'top'});
You will see that all tooltips in your long paragraph have working tooltips with just that one line.
In the jsFiddle example (link above), I also added a situation where one tooltip (by the Sign-In button) is ON by default. Also, the tooltip code is ADDED to the button in jQuery, not in the HTML markup.
Popovers do work the same as the tooltips:
$('[data-toggle="popover"]').popover({trigger: 'hover','placement': 'top'});
And there you have it! Success at last.
One of the biggest problems in figuring this stuff out was making bootstrap work with jsFiddle... Here's what you must do:
NOW you are ready to go.
You just need to enable the tooltip:
$('some id or class that you add to the above a tag').popover({
trigger: "hover"
})
For some reason the only way I was able to get my code to work is by switching couple of things. If nothing worked for you so far, please give a whirl to this:
$('body').popover({
selector: '[data-toggle="popover"]',
trigger: 'hover',
placement: 'right'
});
You have a syntax error in your script and, as noted by xXPhenom22Xx, you must instantiate the tooltip.
<script type="text/javascript">
$(document).ready(function() {
$('.btn-danger').tooltip();
}); //END $(document).ready()
</script>
Note that I used your class "btn-danger". You can create a different class, or use an id="someidthatimakeup"
.