02.06.2015 Views

Bootstrap Tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER<br />

40<br />

<strong>Bootstrap</strong> Popover Plugin<br />

The popover is similar to tooltip, offering an extended view complete with a heading. For the popover to<br />

activate, a user just needs to hover the cursor over the element. The content of the popover can be populated<br />

entirely using the <strong>Bootstrap</strong> Data API. This method requires a tooltip.<br />

If you want to include this plugin functionality individually, then you will need popover.js and it has a dependency<br />

of tooltip plugin. Else, as mentioned in the chapter <strong>Bootstrap</strong> Plugins Overview, you can include bootstrap.js or the<br />

minified bootstrap.min.js.<br />

Usage<br />

The popover plugin generates content and markup on demand, and by default places popover after their trigger<br />

element. You can add popover in the following two ways:<br />

Via data attributes: To add a popover, add data-toggle="popover" to an anchor/button tag. The title of the<br />

anchor will be the text of a popover. By default, popover is set to top by the plugin.<br />

<br />

Hover over me<br />

<br />

Via JavaScript: Enable popovers via JavaScript using the following syntax:<br />

$('#identifier').popover(options)<br />

Popover plugin is NOT only-css plugins like dropdown or other plugins discussed in previous chapters. To use this<br />

plugin you MUST activate it using jquery (read javascript). To enable all the popovers on your page just use this<br />

script:<br />

$(function () { $("[data-toggle='popover']").popover(); });<br />

EXAMPLE<br />

The following example demonstrates the use of popover plugin via data attributes.<br />

<br />

<br />

Popover on left<br />

TUTORIALS POINT<br />

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!