Tooltip & Popover
Tooltip and Popover are close cousins — both show extra text near an element on hover or click — but
they're the two plugins in this whole suite that refuse to work out of the box.
Unlike Modal or Dropdown, adding a data-toggle attribute alone does nothing. You must
explicitly initialize every tooltip and popover with a line of jQuery, typically inside
$(document).ready().
data-placement itself.Required Initialization
Both plugins need this call before they'll do anything. Run it once the DOM is ready:
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
});
bootstrap.min.js — its Tooltip/Popover code computes placement itself.Tooltip: title + data-placement
A tooltip's text comes from the standard title attribute; data-placement picks which side it appears on (top, bottom, left, right).
<!-- TrailMap: tooltip on a difficulty icon -->
<i class="fa fa-fire text-danger"
data-toggle="tooltip"
data-placement="top"
title="Hard: steep, sustained climb"></i>
Popover: adds data-content
A popover is a bigger, click-triggered version of a tooltip: title becomes its heading, and data-content supplies the body text.
<!-- TrailMap: popover on a "?" help icon -->
<a href="#" class="btn btn-default btn-xs"
data-toggle="popover"
data-placement="right"
title="Difficulty Rating"
data-content="Based on elevation gain, trail surface, and average hiker time.">?</a>
With the initialization block from above already on the page, both of these work immediately — hovering the difficulty icon shows the tooltip, and clicking the "?" opens the popover.