Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test for #14244. #15425

Merged
merged 1 commit into from
Dec 30, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions js/tests/unit/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,42 @@ $(function () {
$div.find('a.second').click()
equal($('.popover').length, 0, 'second popover removed')
})

test('should detach popover content rather than removing it so that event handlers are left intact', function () {
var $content = $('<div class="content-with-handler"><a class="btn btn-warning">Button with event handler</a></div>').appendTo('#qunit-fixture')

var handlerCalled = false;
$('.content-with-handler .btn').click(function () {
handlerCalled = true
});

var $div = $('<div><a href="#">Show popover</a></div>')
.appendTo('#qunit-fixture')
.bootstrapPopover({
html: true,
trigger: 'manual',
container: 'body',
content: function () {
return $content;
}
})

stop()
$div
.one('shown.bs.popover', function () {
$div
.one('hidden.bs.popover', function () {
$div
.one('shown.bs.popover', function () {
$('.content-with-handler .btn').click()
$div.bootstrapPopover('destroy')
ok(handlerCalled, 'content\'s event handler still present')
start()
})
.bootstrapPopover('show')
})
.bootstrapPopover('hide')
})
.bootstrapPopover('show')
})
})