2 clicks to open the popover again

2

I'm creating a popopver where I put a close button on it. As shown below in the image:

HTML:

<divclass="dropdown" style="float: right;">
  <button type="button" class="btn btn-default btn-xs popover-markup" data-placement="bottom" style="margin-right: 10px">Preferências</button>
  <div class="head hide">Opção do cliente <a  class="close" href="#");">&times;</a></div>
  <div class="content hide">
    <div class="form-group">
      <input type="checkbox" name="vehicle" class="checkbox-avatar-store"> Lojas do cliente<br>
    </div>
    <div class="form-group">
      <input type="checkbox" name="vehicle" class="checkbox-competition"> Lojas concorrentes<br>
    </div>
  </div>
</div>

JQuery:

$('.popover-markup').popover({
    html: true,
    title: function () {
        return $(this).parent().find('.head').html();
    },
    content: function () {
        return $(this).parent().find('.content').html();
    }
}).on('shown.bs.popover', function () {
    var $popup = $(this);
    $(this).next('.popover').find('a.close').click(function (e) {
        $popup.popover('hide');
    });
});

After it is closed using the popover('hide') method, as shown in the code above, you can only open it again by double-clicking the Preferences button. Because? Should not open with just 1 click? How can I resolve this problem?

    
asked by anonymous 25.08.2017 / 05:01

1 answer

0

Change $popup.popover('hide') usage by $popup.popover('toggle') .

Add the following code to your script:

$('body').on('hidden.bs.popover', function (e) {
    $(e.target).data("bs.popover").inState = { click: false, hover: false, focus: false }
});
    
25.08.2017 / 05:12