jQuery Popover content loses bound events on second setContent call.
Created by: mauvm
When using a jQuery object as content ($el.popover( { content: $form } )), the form and form elements lose their bound events on second setContent call. When the popover is shown for second time, for example.
This happens because of a jQuery memory leak fix (explanation here, proof here). jQuery's html() method (used in Popover.prototype.setContent) internally uses this.empty().append( value ); and therefore removes the content before appending it again.
I suggest changing:
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
Into something like:
if (this.options.html) {
$(content).appendTo($tip.find('.popover-content'))
} else {
$tip.find('.popover-content').text(content)
}
Which fixes the issue. Note that even if content is a jQuery object, it is wrapped again, to support DOM nodes and HTML strings.