mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-30 22:52:24 +01:00
Use closest .alert
for alert dismissal; closes #14306
This commit is contained in:
parent
14e8ec2514
commit
75bffd84ae
@ -36,7 +36,7 @@
|
|||||||
if (e) e.preventDefault()
|
if (e) e.preventDefault()
|
||||||
|
|
||||||
if (!$parent.length) {
|
if (!$parent.length) {
|
||||||
$parent = $this.hasClass('alert') ? $this : $this.parent()
|
$parent = $this.closest('.alert')
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent.trigger(e = $.Event('close.bs.alert'))
|
$parent.trigger(e = $.Event('close.bs.alert'))
|
||||||
|
@ -30,7 +30,7 @@ $(function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should fade element out on clicking .close', function () {
|
test('should fade element out on clicking .close', function () {
|
||||||
var alertHTML = '<div class="alert-message warning fade in">'
|
var alertHTML = '<div class="alert alert-danger fade in">'
|
||||||
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
||||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
@ -42,17 +42,17 @@ $(function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('should remove element when clicking .close', function () {
|
test('should remove element when clicking .close', function () {
|
||||||
var alertHTML = '<div class="alert-message warning fade in">'
|
var alertHTML = '<div class="alert alert-danger fade in">'
|
||||||
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
+ '<a class="close" href="#" data-dismiss="alert">×</a>'
|
||||||
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
|
||||||
+ '</div>'
|
+ '</div>'
|
||||||
var $alert = $(alertHTML).appendTo('#qunit-fixture').bootstrapAlert()
|
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()
|
$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 () {
|
test('should not fire closed when close is prevented', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user