0

I want to use select2 in a bootstrap popover for multiple selection. Selection works fine.

enter image description here

But when I click on x to remove some element, the popover closes itself and only the selection stays. enter image description here

How can I solve this problem?

Peter
  • 1,011
  • 2
  • 16
  • 39

1 Answers1

0

you can prevent popover dismiss when click

$(document).on('click', function (e) {
   $('[data-toggle="popover"],[data-original-title]').each(function () {
    //the 'is' for buttons that trigger popups
    //the 'has' for icons within a button that triggers a popup
    if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {                
        (($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false  // fix for BS 3.3.6
    }

   });
});

you can see more here: https://stackoverflow.com/a/14857326/3344953

Ryan Nghiem
  • 2,417
  • 2
  • 18
  • 28