[英]Select2 search input not working on bootstrap5
I cannot click on the search input dropdown.我无法单击搜索输入下拉菜单。 First of all, I already googled and this is a common problem for select2 with bootstrap3 or bootstrap4, however for bootstrap 5 its a little bit different (I tried remove z-index on bootstrap 4 and its working), I already tried solutions like z-index,
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
首先,我已经用谷歌搜索了,这是使用 bootstrap3 或 bootstrap4 的 select2 的常见问题,但是对于 bootstrap 5,它有点不同(我尝试在 bootstrap 4 上删除 z-index 及其工作),我已经尝试过像 z 这样的解决方案-index,
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
, $('#mySelect2').select2({ dropdownParent: $('#myModal') });
,
$('#mySelect2').select2({ dropdownParent: $('#myModal') });
, and several css but still wont work. , 和几个 css 但仍然无法正常工作。
Maybe im missing something im not sure, its been like 4 days, hope u guys can help me.也许我错过了一些我不确定的东西,已经有 4 天了,希望你们能帮助我。
Really not sure why, but dropdownParent will fix it.真的不知道为什么,但 dropdownParent 会修复它。
$('.select2').each(function () {
$(this).select2({
theme: 'bootstrap-5',
dropdownParent: $(this).parent(),
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.