DropdownSelect2插件无法搜索

问题描述 投票:0回答:1
javascript html dropdown jquery-select2
1个回答
0
投票
不清楚为什么您不能在下拉列表的搜索过滤器中输入文本。因为您说的是滤镜显示的,所以我必须假设Select2已正确初始化。 nonyway值得一提的是,您没有在示例中包括所需的jQuery资产,也没有与您分享实际渲染的html。

在此演示中,我只是用实际渲染的HTML替换了ASP.NET代码,并且表现正确。

因此,如果您仍然遇到了您描述的问题,我必须说罪魁祸首超出了您到目前为止的共享。

.input-group .form-control { height: 34px; border-radius: 0; } .input-group-addon .form-control { height: 34px; border-radius: 0; } .cust-addon { padding: 0px !important; } .Select2-fixed-width+.select2-container { display: block !important; width: 200px !important; font-size: 12px !important; }

<!-- added jQuery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script> <script> $(document).ready(function() { $(".searchfilter").select2(); }); </script> <!-- I expanded your code to mimic real rendered html --> <span class="input-group-addon p-0 cust-addon"> <!-- Here I added the searchfilter class since that's the selector you used to init the select2 --> <select class="searchfilter form-control Select2-fixed-width"> <option value="">Please Select</option> <option value="+1">+1 (United States)</option> <option value="+44">+44 (United Kingdom)</option> <option value="+91">+91 (India)</option> <option value="+33">+33 (France)</option> <option value="+49">+49 (Germany)</option> </select> </span>


    
	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.