我已经为这个问题争论了一个多星期,但几乎没有任何进展。
我看过
最后,查看https://select2.org/troubleshooting/common-problems后
我尝试同时应用dropdownParent: $('#myModal')和
// Do this before you initialize any of your modals
$.fn.modal.Constructor.prototype.enforceFocus = function() {};
Run Code Online (Sandbox Code Playgroud)
这些修复都不起作用,所以我真的束手无策,准备完全放弃使用模式。基本上,我从服务器获取 JSON 对象中的数据,然后使用该数据填充模式。除第一个组合框之外的所有元素(其中一些是选择/组合框)的填充工作正常。
预先感谢您的帮助,如果答案发布在其他地方,我很抱歉,但我找不到它。以下是相关代码:
<!-- Modal to Add / Edit Delay parent div must have same id as value of the data-target attribute used to trigger the modal -->
<div class="modal fade" id="delayAddModal" tabindex="-1" role="dialog" aria-labelledby="delayAddLabel">
<div class="modal-dialog" role="document">
<!-- …Run Code Online (Sandbox Code Playgroud) javascript asp.net-mvc jquery jquery-select2 bootstrap-modal