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.

Usage<br />

Following table lists the classes collapse plugin utilizes to handle the heavy lifting:<br />

Class<br />

.collapse<br />

.collapse.in<br />

.collapsing<br />

Description<br />

hides the content<br />

shows the content<br />

is added when the transition starts, and removed when it finishes<br />

You can use collapse plugin in two ways:<br />

<br />

<br />

Via data attributes: Add data-toggle="collapse" and a data-target to the element to automatically assign<br />

control of a collapsible element. The data-target attribute will accept a CSS selector to apply the collapse to.<br />

Be sure to add the class .collapse to the collapsible element. If you’d like it to default open, include the<br />

additional class .in.<br />

To add accordion-like group management to a collapsible control, add the data attribute dataparent="#selector".<br />

Via JavaScript: The collapse method can activated with JavaScript as below:<br />

$('.collapse').collapse()<br />

Options<br />

There are certain options which can be passed via data attributes or JavaScript are listed in the following table:<br />

Option<br />

Name<br />

Type/Default<br />

Value<br />

Data<br />

attribute<br />

name<br />

Description<br />

Parent<br />

selector<br />

Default: false<br />

data-parent<br />

If selector then all collapsible elements under the specified parent will<br />

be closed when this collapsible item is shown. (similar to traditional<br />

accordion behavior - this dependent on the accordion-group class)<br />

Toggle<br />

boolean<br />

Default: true<br />

data-toggle<br />

Toggles the collapsible element on invocation.<br />

Methods<br />

The following are some methods useful to use with collapsible elements.<br />

Method Description Example<br />

Options:.collapse(options)<br />

Activates your content as a<br />

collapsible element. Accepts an<br />

optional options object.<br />

$('#identifier').collapse({<br />

toggle: false<br />

})<br />

TUTORIALS POINT<br />

Simply Easy Learning

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

Saved successfully!

Ooh no, something went wrong!