Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option.accordion (if false panels behave as basic collapse) #46

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions bootstrap-tabcollapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
};

TabCollapse.DEFAULTS = {
accordion: true,
accordionClass: 'visible-xs',
tabsClass: 'hidden-xs',
accordionTemplate: function(heading, groupId, parentId, active) {
Expand Down Expand Up @@ -138,9 +139,13 @@
$el.attr({
'data-toggle-was': $el.attr('data-toggle'),
'data-toggle': 'collapse',
'data-parent': '#' + parentId,
href: href
'href': href
});
if ( this.options.accordion ) {
$el.attr({
'data-parent': '#' + parentId,
});
}
});
}

Expand All @@ -161,9 +166,13 @@
$heading.addClass('js-tabcollapse-panel-heading ' + (active ? '' : 'collapsed'));
$heading.attr({
'data-toggle': 'collapse',
'data-parent': '#' + parentId,
'href': '#' + groupId
});
if ( this.options.accordion ) {
$heading.attr({
'data-parent': '#' + parentId,
});
}
return $heading;
};

Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ To activate tab collapse just include **bootstrap-tabcollapse.js** somewhere in

$('#myTab').tabCollapse();

By default tab collapse behave like accordion (always only active panel is visible / uncollapsed).
If you want to use simple collapse (more panels can be visible/uncollapsed at the same time),
set option "accordion" to "false":

$('#myTab').tabCollapse({
accordion: false
});

If you want to specify the class that is given to accordion and tabs components you can do so by passing options to `tabCollapse`:

$('#myTab').tabCollapse({
Expand Down