1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-18 03:11:19 +02:00

Collapse - Allow to pass jQuery object or DOM element to the parent option

This commit is contained in:
Johann-S
2017-09-25 12:41:54 +02:00
parent 3abf8a0e55
commit 9b8356ba52
4 changed files with 64 additions and 9 deletions

View File

@@ -698,4 +698,48 @@ $(function () {
$target.trigger($.Event('click'))
})
QUnit.test('should allow jquery object in parent config', function (assert) {
assert.expect(1)
var html =
'<div class="my-collapse">' +
' <div class="item">' +
' <a data-toggle="collapse" href="#">Toggle item</a>' +
' <div class="collapse">Lorem ipsum</div>' +
' </div>' +
'</div>'
$(html).appendTo('#qunit-fixture')
try {
$('[data-toggle="collapse"]').bootstrapCollapse({
parent: $('.my-collapse')
})
assert.ok(true, 'collapse correctly created')
}
catch (e) {
assert.ok(false, 'collapse not created')
}
})
QUnit.test('should allow DOM object in parent config', function (assert) {
assert.expect(1)
var html =
'<div class="my-collapse">' +
' <div class="item">' +
' <a data-toggle="collapse" href="#">Toggle item</a>' +
' <div class="collapse">Lorem ipsum</div>' +
' </div>' +
'</div>'
$(html).appendTo('#qunit-fixture')
try {
$('[data-toggle="collapse"]').bootstrapCollapse({
parent: $('.my-collapse')[0]
})
assert.ok(true, 'collapse correctly created')
}
catch (e) {
assert.ok(false, 'collapse not created')
}
})
})