Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap: Hide other popovers when one is open

The following Bootstrap code gives me "sticky" popover (so users can interact with the content inside the popover). The issue is that when a popover is opened, other popovers should be closed (hidden). Any idea how I can implement this?

$("[rel=popover]").popover({placement:'bottom', trigger:'manual'}).hover(function(){
    $(this).popover('show');
    e.preventDefault(); 
});
like image 925
farjam Avatar asked Feb 07 '13 20:02

farjam


People also ask

What is data toggle popover?

The Popover plugin is similar to tooltips; it is a pop-up box that appears when the user clicks on an element. The difference is that the popover can contain much more content. Click To Toggle Popover Click To Toggle Popover.

How does bootstrap define popover?

A Bootstrap Popover is an attribute in bootstrap that can be used to make any website look more dynamic. Popovers are generally used to display additional information about any element and are displayed with a click of a mouse pointer over that element.


2 Answers

There's a very simple solution here (not my solution, but works beautifully):

$('.link-popover').click(function(){
    $('.link-popover').not(this).popover('hide'); //all but this
});
like image 171
adam Avatar answered Oct 18 '22 05:10

adam


As per the bootstrap docs: Use the focus trigger to dismiss popovers on the next click that the user makes.

<a href="#" tabindex="0" class="btn btn-lg btn-danger" role="button" data-toggle="popover" data-   trigger="focus" title="Dismissible popover" data-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>
like image 42
alexoviedo999 Avatar answered Oct 18 '22 05:10

alexoviedo999