I'm trying to place select2 dropdown in my popover - select2 dropdown is rendering normally when I open popover for the first time, but if I close it and open again - it renders 2 select2 dropdowns, one of which is unclickable:
I've already tried z-index
solution from here and the solution from here, and they didn't work.
I've also read that select2 doesn't work properly in Bootstrap modal's and also tried to render it with dropdownParent
property - didn't work too.
My HTML:
<div class="actions-row mb-5">
<button type="button" class="btn popover-toggle add-to-program-popover" data-placement="bottom">
Add to program
</button>
<div class="program-container" style="display: none">
<select name="movement-program-select" class="movement-program-select">
<option value=""></option>
<option value="Program 1">Program 1</option>
<option value="Program 2">Program 2</option>
<option value="Program 3">Program 3</option>
</select>
<i class="fa fa-floppy-o add-to-program" aria-hidden="true"></i>
<hr>
<a class="create-new-program">
<i class="fa fa-plus-square-o add-item"></i>
Create new program</a>
</div>
</div>
This is my JS code:
$('button.add-movement-to-program').on('click', function(e) {
$('.add-to-program-table-container').show();
});
$('button.add-to-program-popover').popover({
container: 'main',
html: true,
content: function() {
return $('.program-container').html();
}
});
$('button.add-to-program-popover').click(function() {
// console.log(1);
// if (!$('.movement-program-select').hasClass("select2-hidden-accessible")) {
// console.log(2);
$('.movement-program-select').select2({
container: 'body',
width: "100%",
dropdownParent: $('.popover-content')
});
// }
});
Are there any other variants on how it can be fixed?
Here is a link to my JSFiddle: http://jsfiddle.net/fpk047rh/1/