Created
May 19, 2016 23:21
-
-
Save allusis/872cc9035c087c891a2848c0aabb7752 to your computer and use it in GitHub Desktop.
Custom Bootstrap Popover Content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a data-toggle="popover" class="popper" data-placement="top">Link</a> | |
<div class="popover-content hide"> | |
<!-- Content --> | |
</div |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.popper').popover({ | |
container: 'body', | |
html: true, | |
content: function () { | |
return $(this).next('.popover-content').html(); | |
} | |
}); | |
// Close the popover when anything else is clicked | |
$('body').on('click', function (e) { | |
$('[data-toggle="popover"]').each(function () { | |
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) { | |
$(this).popover('hide'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment