JS:
$(function(){
$("#example").popover({
placement: 'bottom',
html: 'true',
title : '<span class="text-info"><strong>title</strong></span> <button type="button" id="close" class="close">×</button>',
content : 'test'
})
$('html').click(function() {
$('#close').popover('hide');
});
});
HTML:
<button type="button" id="example" class="btn btn-primary" ></button>
i'm write your code isn't show your popup.
anyone come across this problem?
When you click element and show your popup, next you can raise event shown.bs.popover where in this you get element in which trigger click to close your popover.
Try this:
Rather than adding the button as a string of markup, it's much easier if you have a jQuery wrapped button because then you can bind much more neatly. This is indeed sadly missing from the Bootstrap code, but this workaround works for me, and actually could be expanded to apply to all popovers if desired.
The following is what i just used in my project .And hope it can help you
As a very simple solution to this, I did the following:
1) Add the following CSS:
2) Set
data-trigger="manual"
on the popover trigger element3) Then based on https://github.com/twbs/bootstrap/issues/16802:
This uses the basis that anywhere on the popover is clickable but by focusing on the cross you'll encourage the behaviour you're after.
You need to make the markup right
Then, one way is to attach the close-handler inside the element itself, the following works :