Take the 2-minute tour ×

Here is my code:


I tried to close the popover when clicking outside of the content and the button but there's an issue with its content. Apparently I can't hide or destroy the content completely.

When I toggle the popover with the 'trigger' link, it works fine. But whenever I close it by clicking outside of the content, I can still hover the link in the content.

Any solution for this please?

share|improve this question
add comment

4 Answers

up vote 0 down vote accepted

Heres a link to working example: http://codepen.io/anon/pen/zhIsm I just keep latest trigger and click it, whenever document is clicked.

share|improve this answer
There is a bit of problem. After you trigger one, and you hide it, the next time you click anywhere in the document it will re-open the last hidden popover. –  JofryHS Sep 16 '13 at 1:50
yes, missed that case, fixed. –  Yaroslav Yakovlev Sep 16 '13 at 2:03
Thank you! It works perfectly! –  greywind Sep 16 '13 at 3:42
add comment

I think you mess with the internal mechanism too much.

Here is the working fiddle: http://codepen.io/anon/pen/utbin

If the target isn't the trigger, just toggle the existing open popover.

share|improve this answer
Thanks mate. It works but can you make it as if one popover is open, when you click on the other 'trigger', it closes the opened popover before displaying the clicked one? At the moment they overlapped each other. –  greywind Sep 16 '13 at 4:48
@greywind then you will need to manually register the 'click' event to check for existing open popover. I believe Yaroslaw answer covered it. :) –  JofryHS Sep 16 '13 at 5:01
add comment

Here is another way (will work with data-api too) http://jsbin.com/aRiZiki/1/edit

share|improve this answer
add comment

This is what I did in order to prevent elements within the hidden popover from being clicked

$('button.new-history').on('hidden.bs.popover', function () {

The idea being that when the popover is hidden, you should remove it from the DOM.

Hope it helps!

share|improve this answer
add comment

Your Answer


