Я использую Select2 (версия 4.0.5) на веб-странице.
Когда моя модель использует более 5 текстовых полей, я не могу установить фокус на select2 окно поиска. Фокус работает должным образом, если я удаляю одно текстовое поле в моей модели.
Кто-нибудь знает почему?
<div id="addModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<form>
<div class="modal-header alert-info">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Add SubToSub Menu</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label>SubMenuName</label>
<select class="form-control AddSubMenu123" style="width: 100%;"></select>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ProgramName, new { @class = "control-label" })
<input type="text" id="txtAddProgramId" name="ProgramID" />
</div>
<div class="form-group">
<input type="text" id="txtAddProgramName" name="ProgramName" class="form-control" />
<input type="text" id="chkProgramId" onclick="CheckProgramId()">IsProgram
</div>
<div class="form-group ">
@Html.LabelFor(model => model.SubToSubMenuName, new { @class = "control-label" })
@Html.EditorFor(model => model.SubToSubMenuName, new { htmlAttributes = new { @class = "form-control required ", @id = "txtAddCode", @placeholder = "required" } })
@Html.ValidationMessageFor(model => model.SubToSubMenuName)
</div>
<div class="form-group ">
@Html.LabelFor(model => model.MyanmarSubToSubMenuName, new { @class = "control-label" })
@Html.EditorFor(model => model.MyanmarSubToSubMenuName, new { htmlAttributes = new { @class = "form-control required", @id = "txtAddMyanmarSubToSubMenuName", @placeholder = "required" } })
@Html.ValidationMessageFor(model => model.MyanmarSubToSubMenuName)
</div>
<div class="form-group ">
@Html.LabelFor(model => model.Description, new { @class = "control-label" })
@Html.EditorFor(model => model.Description, new { htmlAttributes = new { @class = "form-control required", @id = "txtAddDesp", @placeholder = "required" } })
@Html.ValidationMessageFor(model => model.Description)
</div>
</div>
<div class="modal-footer">
<input type="submit" class="btn btn-success pull-left Button100Px submit" value=@RMS8.Resources.ResourceDefault.Save>
<input type="button" class="btn btn-info pull-left Button100Px" data-dismiss="modal" value=@RMS8.Resources.ResourceDefault.Cancel>
</div>
</form>
</div>
</div>
</div>
Выбор2 инициализация
$('.AddSubMenu123').select2({
placeholder: 'select one',
allowClear: true,
ajax: {
url: '/SubMenu/GetSubMenuList',
dataType: 'json',
data: function(params) {
return {
prefix: params.term,
}
},
processResults: function(data) {
return {
results: $.map(data, function(item) {
return {
id: item.val,
text: item.label,
}
})
};
}
},
});
});