From: Chris Rebert Date: Mon, 22 Dec 2014 22:02:31 +0000 (-0800) Subject: Add regression test for #14244. X-Git-Tag: v3.3.2~5^2~60^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=27bfef5b35f3e12af8beb7140e3b19bb6a3b3a75;p=thirdparty%2Fbootstrap.git Add regression test for #14244. Special thanks to @programcsharp [skip validator] --- diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 466ebace26..4b8b2a96bf 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 = $('
Button with event handler
').appendTo('#qunit-fixture') + + var handlerCalled = false; + $('.content-with-handler .btn').click(function () { + handlerCalled = true + }); + + var $div = $('
Show popover
') + .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') + }) })