Bootstrap Popover - Close on click anywhere
I'm just wondering if this is a good way to do it or if I'm being stupid.
Basically any click in body is verified to not be the popover anchor, or
within the popover. If it's not, then it hides all popovers.
$("body").on('click', function(e) {
if(!$(event.target).hasClass('with-popover') &&
!$(event.target).parents('.with-popover').length &&
!$(event.target).parents('.popover').length){
$(".with-popover").popover('hide');
};
});
return true;
});
No comments:
Post a Comment