我正在处理文本框的自动完成功能,并且需要一次获取十个结果,并且选项可以获得更多超链接。目前它取得了所有结果。
到目前为止我的代码附在下面。你能提供指导吗?
$(document).ready(function(){
$('#<%=txtEmployeeName.ClientID%>').autocomplete({
source: function (request, response) {
$("#loading").show();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "AccountDisclosureSearch.aspx/SearchEmpByText",
data: "{ 'empName':'" + request.term + "'}",
dataType: "json",
success: function (data) {
response($.map(data.d, function (item) {
return {
label: item.split(";")[0],
val: item.split(";")[1]
// name: item.split("|")[0]
}
}))
$("#loading").hide();
},
error: function (response) {
alert(response.responseText);
$("#loading").hide();
}
});
},
select: function (e, i) {
// $("#<%=hempid.ClientID %>").val(i.item.val);
storeEmployee(i.item.label, 0, i.item.val);
},
open: function(){
$('.ui-autocomplete').css('width', '220px');
},
minLength: 3
});
});
答案 0 :(得分:0)
您可以使用maxResults
或maxShowItems
,如下所示:
$(document).ready(function(){
$('#<%=txtEmployeeName.ClientID%>').autocomplete({
maxResults:10,
or
maxShowItems:10,
or
maxHeight: 150,
source: function (request, response) {
//whatever you have
}
});
});
有关详细信息,请查看Here