Select2搜索输入在bootstrap5上不工作



我不能点击搜索输入下拉菜单。首先,我已经谷歌,这是一个常见的问题为select2与bootstrap3或bootstrap4,然而,对于bootstrap 5它有点不同(我试图删除z-index上的bootstrap4和它的工作),我已经尝试了解决方案,如z-index,$.fn.modal.Constructor.prototype.enforceFocus = function() {};,$('#mySelect2').select2({ dropdownParent: $('#myModal') });,和几个css,但仍然不能工作。

也许我错过了什么,我不确定,已经有4天了,希望你们能帮助我。

这里jsFiddle:jsfiddle

真的不知道为什么,但是dropdownParent会修复它。

$('.select2').each(function () {
$(this).select2({
theme: 'bootstrap-5',
dropdownParent: $(this).parent(),
});
});

在我的例子中,选择显示在对话框模态表单上。

当我删除modal=true,然后它工作

最新更新