diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 466ebace26d5141298886eeb41e20285c69ff6ca..4b8b2a96bf7a6e79024791d3ae59e6d08b40075a 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -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') + }) })