diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js index 2730a48d45..813462a24e 100644 --- a/js/bootstrap-collapse.js +++ b/js/bootstrap-collapse.js @@ -160,6 +160,12 @@ || e.preventDefault() || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 , option = $(target).data('collapse') ? 'toggle' : $this.data() + , parent = $this.attr('data-parent') + , $parent = parent && $(parent) + + if ($parent) { + $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed') + } $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') $(target).collapse(option) }) diff --git a/js/tests/unit/bootstrap-collapse.js b/js/tests/unit/bootstrap-collapse.js index 4c5916ecd9..dbbf5dcf1f 100644 --- a/js/tests/unit/bootstrap-collapse.js +++ b/js/tests/unit/bootstrap-collapse.js @@ -91,4 +91,39 @@ $(function () { target.click() }) + test("should remove active class from inactive accordion targets", function () { + $.support.transition = false + stop() + + var accordion = $('