diff --git a/js/collapse.js b/js/collapse.js index d7d56bdd5e..abbf25f2a6 100644 --- a/js/collapse.js +++ b/js/collapse.js @@ -38,17 +38,21 @@ Collapse.prototype.show = function () { if (this.transitioning || this.$element.hasClass('in')) return + var activesData + var actives = this.$parent && this.$parent.find('> .panel').children('.in, .collapsing') + + if (actives && actives.length) { + activesData = actives.data('bs.collapse') + if (activesData && activesData.transitioning) return + } + var startEvent = $.Event('show.bs.collapse') this.$element.trigger(startEvent) if (startEvent.isDefaultPrevented()) return - var actives = this.$parent && this.$parent.find('> .panel').children('.in, .collapsing') - if (actives && actives.length) { - var hasData = actives.data('bs.collapse') - if (hasData && hasData.transitioning) return Plugin.call(actives, 'hide') - hasData || actives.data('bs.collapse', null) + activesData || actives.data('bs.collapse', null) } var dimension = this.dimension() diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 825f79360e..c1d78575c6 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -263,4 +263,39 @@ $(function () { $target3.click() }) + test('should not fire show event if show is prevented because other element is still transitioning', function () { + stop() + + var accordionHTML = '
' + + '
' + + '
' + + '
' + var showFired = false + var $groups = $(accordionHTML).appendTo('#qunit-fixture').find('.panel') + + var $target1 = $('').appendTo($groups.eq(0)) + + $('