Select2 not working inside bootstrap modal
place this somewhere in your JS:
//fix modal force focus
$.fn.modal.Constructor.prototype.enforceFocus = function () {
var that = this;
$(document).on('focusin.modal', function (e) {
if ($(e.target).hasClass('select2-input')) {
return true;
}
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus();
}
});
};
Use bellow code. This will solve your bug.
$('select').select2({
dropdownParent: $('#my_amazing_modal')
});