diff --git a/js/alert.js b/js/alert.js index 5389c32e99..10483899df 100644 --- a/js/alert.js +++ b/js/alert.js @@ -36,7 +36,7 @@ if (e) e.preventDefault() if (!$parent.length) { - $parent = $this.hasClass('alert') ? $this : $this.parent() + $parent = $this.closest('.alert') } $parent.trigger(e = $.Event('close.bs.alert')) diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js index 52505c828d..bc4eed6765 100644 --- a/js/tests/unit/alert.js +++ b/js/tests/unit/alert.js @@ -30,7 +30,7 @@ $(function () { }) test('should fade element out on clicking .close', function () { - var alertHTML = '
' + var alertHTML = '
' + '×' + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + '
' @@ -42,17 +42,17 @@ $(function () { }) test('should remove element when clicking .close', function () { - var alertHTML = '
' + var alertHTML = '
' + '×' + '

Holy guacamole! Best check yo self, you\'re not looking too good.

' + '
' var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert() - notEqual($('#qunit-fixture').find('.alert-message').length, 0, 'element added to dom') + notEqual($('#qunit-fixture').find('.alert').length, 0, 'element added to dom') $alert.find('.close').click() - equal($('#qunit-fixture').find('.alert-message').length, 0, 'element removed from dom') + equal($('#qunit-fixture').find('.alert').length, 0, 'element removed from dom') }) test('should not fire closed when close is prevented', function () {