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.

All methods accept an optional options object, a string which targets a particular method, or nothing (which initiates<br />

a plugin with default behavior) as shown below:<br />

// initialized with defaults<br />

$("#myModal").modal()<br />

// initialized with no keyboard<br />

$("#myModal").modal({ keyboard: false })<br />

// initializes and invokes show immediately<br />

$("#myModal").modal('show')<br />

Each plugin also exposes its raw constructor on a Constructor property: $.fn.popover.Constructor. If you'd like to<br />

get a particular plugin instance, retrieve it directly from an element:<br />

$('[rel=popover]').data('popover').<br />

No Conflict<br />

<strong>Bootstrap</strong> plugins can sometimes be used with other UI frameworks. In these circumstances, namespace collisions<br />

can occasionally occur. To overcome this call .noConflict on the plugin you wish to revert the value of.<br />

// return $.fn.button to previously assigned value<br />

var bootstrapButton = $.fn.button.noConflict()<br />

// give $().bootstrapBtn the <strong>Bootstrap</strong> functionality<br />

$.fn.bootstrapBtn = bootstrapButton<br />

Events<br />

<strong>Bootstrap</strong> provides custom events for most plugin's unique actions. Generally, these events come in two forms:<br />

Infinitive form: This is triggered at the start of an event. ex: show. Infinitive events<br />

providepreventDefault functionality. This provides the ability to stop the execution of an action before it starts.<br />

$('#myModal').on('show.bs.modal', function (e) {<br />

// stops modal from being shown<br />

if (!data) return e.preventDefault()<br />

})<br />

<br />

Past participle form: This is triggered on the completion of an action. ex: shown<br />

TUTORIALS POINT<br />

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!