admin管理员组文章数量:1394099
Im using this Select2 plugin in dropdown at my partial view. The textbox is coming on the dropdown but i couldnt type anything inside that textbox. I need an asssist here.
<link href="~/Content/Multiselect/select2.min.css" rel="stylesheet" />
<!-- Select2 JS -->
<script src="~/Content/Multiselect/select2.min.js"></script>
<script>
$(".searchfilter").select2();
</script>
<span class="input-group-addon p-0 cust-addon">
@Html.DropDownListFor(model => model.DialCode, (SelectList)ViewBag.DialCodeList, "Please Select", new { @class = " form-control requiredfield searchfilter Select2-fixed-width", @style = "width: 95px;" })
</span>
<style>
.input-group .form-control {
height: 34px; /* Match height */
border-radius: 0; /* Consistent edges */
}
.input-group-addon .form-control {
height: 34px; /* Match the input height */
border-radius: 0; /* Consistent edges */
}
.cust-addon {
padding: 0px !important;
}
.Select2-fixed-width + .select2-container {
display: block !important; /* Ensure it is displayed correctly */
width: 120px !important;
font-size: 12px !important; /* Adjust the font size as needed */
}
</style>
This is a snippet where the assets are bound to a public cdn showing a working scenario. I still cannot understand what's going wrong in my real case. I was suggested to strip off any other javascript that might be interfering with the event loop or maybe some sync function invocations that might be blocking the UI. Still clueless.
.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=".7.1/jquery.min.js"></script>
<link rel="stylesheet" href=".0.13/css/select2.min.css" />
<script src=".0.13/js/select2.min.js"></script>
<script>
//initialize the select2 dropdown once the document is ready
//this was added compared to the original scenario,
//but yet the dropdown was correctly initialized so maybe it doesn't make any difference
$(document).ready(function() {
$(".searchfilter").select2();
});
</script>
<!-- I expanded your code to mimic real rendered html -->
<span class="input-group-addon p-0 cust-addon">
<!--
@Html.DropDownListFor(
model => model.DialCode,
(SelectList)ViewBag.DialCodeList,
"Please Select",
new {
@class = " form-control requiredfield searchfilter Select2-fixed-width",
@style = "width: 95px;"
}
)
-->
<select class="form-control requiredfield searchfilter Select2-fixed-width" style="width: 95px;">
<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>
本文标签: javascriptDropdown select2 plugin cannot searchStack Overflow
版权声明:本文标题:javascript - Dropdown select2 plugin cannot search - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744574779a2613554.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论