Bootstrap popover, hide on click outside?
I found this : http://bootply.com/99372
$('body').on('click', function (e) {
$('[data-toggle=popover]').each(function () {
// hide any open popovers when the anywhere else in the body is clicked
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
It's almost the same code as you...
Just add this element to close the popover on next click.
data-trigger="focus"
Reference from here: Bootstrap Popover