View on GitHub

bootstrap-collapse

Easy way to make use of bootstrap collapse component

Download this project as a .zip file Download this project as a tar.gz file

Bootstrap Collapse an easy way to use BS's collapse component

Supposing the following examples all use this panel object for the first parameter.

var panel = {
    title: 'Collapse Title',
    body: 'Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven\'t heard of them accusamus labore sustainable VHS.'
};
                    
The Easiest & Simplest Call
$('#collapse').collapse(panel);
Use a Style
$('#collapse').collapse(panel, {style: Collapse.STYLE_DEFAULT});
$('#collapse').collapse(panel, {style: Collapse.STYLE_PRIMARY});
Hide Body By Default
$('#collapse').collapse(panel, {collapse: false, style: Collapse.STYLE_INFO});
Using Method
$('#collapse').collapse(panel, {style: Collapse.STYLE_WARNING});     
          
window.setTimeout(function(){
    $('#collapse').collapse('toggle');
}, 2000);
                    
Event Handlers
$('#collapse').collapse(panel, {
    style: Collapse.STYLE_SUCCESS, 
    beforeShow: function(){
        alert('Header is ' + this.title.text());
    },
    beforeHide: function(){
        alert('I am closing this panel!');
    },
    postShow: function(){
        alert('Hello everybody! Have you got your banana yet?');
    },
    postHide: function(){
        alert('Oops...Bye bye banana!');
    }
});