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:
@@ -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')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user