2

Let's say I have a popover that contains links <a> and some of these links can open modal.

The problem is that this popover is still active when modal is open. How to hide all active popovers when any modal show after clicking on those links inside this popover?

<div class="popover-content">
<ul class="popover-ul">
    <li>
      <a href="#" data-msg="<h4>OUT</h4><img src='yourlinkhere' alt='OUT'>" data-toggle="modal" data-target="#doc-modal" data-ok="data-ok">
      OUT
      </a>
    </li>
</ul>

Mohammed Ali
  • 1,117
  • 1
  • 16
  • 31

3 Answers3

2

You can use popover hide function to hide the popover.

Working Example : http://jsfiddle.net/qy9Az/3414/

$('.test').popover('hide')

in your Case i think this will help

$('body').on('shown.bs.modal', function() {
     $("[data-toggle=popover]").popover('hide')
});

Where test is the class of the element on which popover is attached

See https://v4-alpha.getbootstrap.com/components/popovers/#popoverhide for more details

Mohammed Ali
  • 1,117
  • 1
  • 16
  • 31
Vineesh
  • 3,762
  • 20
  • 37
1

I think this will help

$('body').on('shown.bs.modal', function() {
     $("[data-toggle=popover]").popover('hide')
});
Aspirin_xap
  • 208
  • 1
  • 7
0

I belive i undertand your question set not-visible: hide popovers(any), a fiddle

var _pops = document.getElementsByClassName("popover-content");
console.log(_pops)
for(var i=0; i<_pops.length;i++){
_pops[i].style.visibility = "hidden"
}
Álvaro Touzón
  • 1,247
  • 1
  • 8
  • 21
  • my problem is when i press any link inside the same popover it will show a modal and this popover still active i need this popover to be hidden when pressing link inside it – Mohammed Ali Jul 26 '17 at 11:11