【发布时间】:2015-12-16 13:56:24
【问题描述】:
我现在使用 select2 有一段时间了,但我刚刚开始使用多选。 从一开始我就有同样的问题。
每当我使用最少 1 个字符的要求进行多选下拉菜单时,它都会告诉我“请输入 1 个或更多字符”,对吗?
好吧,当我单击页面中的其他位置时,此弹出窗口仍然存在。
如何解决这个问题?
$("#e1").select2({
minimumInputLength: 1
});
http://jsfiddle.net/Jeanpaul1994/3tfcm83n/1/
编辑
我的多选。 @Html.DropDownListFor(model => model.Visit.ExtraHosts, new List(), null, new { @class= "form-control select2-customselector", @multiple = "multiple" })
我的 Ajax 调用。
$('#@Html.IdFor(model => model.Visit.EmployeeId), #@Html.IdFor(model => model.Visit.ExtraHosts)').select2({
ajax: {
url: '@Url.Action("GetHostsViaAJAX", "Visitors")',
dataType: 'json',
type: "POST",
data: function (params) {
return {
searchTerm: params.term
};
},
processResults: function (data) {
return { results: data };
}
},
placeholder: "@IAMMVCResources.SelectAHost",
minimumInputLength: 1,
allowClear: true
});
【问题讨论】:
-
你好,只是想知道我下面的回答是否解决了你的问题。
-
嗨@jacobheater 我还没有时间测试它,因为现在是早上8点,我会在几分钟内测试它,我会告诉你,它看起来很有希望!
标签: jquery jquery-select2