02.06.2015 Views

Bootstrap Tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER<br />

33<br />

<strong>Bootstrap</strong> Plugins Overview<br />

The components discussed in the previous chapters under Layout Components are just the beginning.<br />

<strong>Bootstrap</strong> comes bundled with 12 jQuery plugins that extend the features and can add more interaction to your<br />

site. To get started with <strong>Bootstrap</strong>’s JavaScript plugins, you don’t need to be an advanced JavaScript developer.<br />

By utilizing <strong>Bootstrap</strong> Data API, most of the plugins can be triggered without writing a single line of code.<br />

<strong>Bootstrap</strong> Plugins can be included on your site in two forms:<br />

Individually: Using <strong>Bootstrap</strong>'s individual *.js files. Some plugins and CSS components depend on other<br />

plugins. If you include plugins individually, make sure to check for these dependencies in the docs.<br />

Or compiled (all at once): Using bootstrap.js or the minified bootstrap.min.js.<br />

Do not attempt to include both, as both bootstrap.js and bootstrap.min.js contain all plugins in a single file.<br />

All plugins depend on jQuery. So jQuery must be included before the plugin files. Check bower.jsonto<br />

see which versions of jQuery are supported.<br />

Data Attributes<br />

All of the <strong>Bootstrap</strong> plugins are accessible using the included Data API. Hence, you don’t need to include a<br />

single line of JavaScript to invoke any of the plugin features.<br />

In some situations it may be desirable to turn this functionality of Data API off. If you need to turn off the Data<br />

API, you can unbind the attributes by adding the following line of JavaScript:<br />

$(document).off('.data-api')<br />

To turn off a specific/single plugin, just include the plugin's name as a namespace along with the data-api<br />

namespace like this:<br />

$(document).off('.alert.data-api')<br />

Programmatic API<br />

The developers of <strong>Bootstrap</strong> believe that you should be able to use all of the plugins purely through the JavaScript<br />

API. All public APIs are single, chainable methods, and return the collection acted upon say for example:<br />

$(".btn.danger").button("toggle").addClass("fat")<br />

TUTORIALS POINT<br />

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!