Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Created January 26, 2017 17:01
Show Gist options
  • Save Farmatique/eb342bd79af331bb256d19055bf13f7d to your computer and use it in GitHub Desktop.
Save Farmatique/eb342bd79af331bb256d19055bf13f7d to your computer and use it in GitHub Desktop.
Bootstrap 3.3.6 close popver by clicking outside of it
$(document).on('click', function (e) {
$('[data-toggle="popover"],[data-original-title]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
(($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false // fix for BS 3.3.6
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment