mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-13 17:14:04 +02:00
handle detached tooltip when we try to hide a modal
This commit is contained in:
@@ -862,6 +862,44 @@ $(function () {
|
||||
.modal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should allow to close modal if the tooltip element is detached', function (assert) {
|
||||
assert.expect(1)
|
||||
var done = assert.async()
|
||||
var templateHTML = [
|
||||
'<div id="modal-test" class="modal">',
|
||||
' <div class="modal-dialog" role="document">',
|
||||
' <div class="modal-content">',
|
||||
' <div class="modal-body">',
|
||||
' <a id="tooltipTest" href="#" data-toggle="tooltip" title="Some tooltip text!">Tooltip</a>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
' </div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
$(templateHTML).appendTo('#qunit-fixture')
|
||||
var $tooltip = $('#tooltipTest')
|
||||
var $modal = $('#modal-test')
|
||||
|
||||
$tooltip.on('shown.bs.tooltip', function () {
|
||||
$tooltip.detach()
|
||||
$tooltip.bootstrapTooltip('dispose')
|
||||
$modal.modal('hide')
|
||||
})
|
||||
|
||||
$modal.on('shown.bs.modal', function () {
|
||||
$tooltip.bootstrapTooltip({
|
||||
trigger: 'manuel'
|
||||
})
|
||||
.bootstrapTooltip('show')
|
||||
})
|
||||
.on('hidden.bs.modal', function () {
|
||||
assert.ok(true, 'modal hidden')
|
||||
done()
|
||||
})
|
||||
.modal('show')
|
||||
})
|
||||
|
||||
QUnit.test('should reset tip classes when hidden event triggered', function (assert) {
|
||||
assert.expect(2)
|
||||
var done = assert.async()
|
||||
@@ -966,4 +1004,24 @@ $(function () {
|
||||
|
||||
assert.ok(tooltip.tip === $tipTest[0])
|
||||
})
|
||||
|
||||
QUnit.test('should toggle enabled', function (assert) {
|
||||
assert.expect(3)
|
||||
|
||||
var $tooltip = $('<a href="#" rel="tooltip" data-trigger="click" title="Another tooltip"/>')
|
||||
.appendTo('#qunit-fixture')
|
||||
.bootstrapTooltip()
|
||||
|
||||
var tooltip = $tooltip.data('bs.tooltip')
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, true)
|
||||
|
||||
tooltip.toggleEnabled()
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, false)
|
||||
|
||||
tooltip.toggleEnabled()
|
||||
|
||||
assert.strictEqual(tooltip._isEnabled, true)
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user