我需要在自动完成时将行号限制为 10。数据来自数据库。有没有像“maxrows”之类的属性?我不想添加卷轴。
请提前建议方法。
我的代码是:
$("#iIdlbl").autocomplete({
source : function(request, response) {
var value = jQuery("#iIdlbl").val();
$.ajax( {
url : 'getiId.html',
dataType : 'json',
data : {
filter : value
},
success : function(data) {
response(jQuery.map(data.iList,function(item) {
return {
value : item.iId,
key : item.iId
};
}));
},
error : function(XMLHttpRequest,textStatus,errorThrown) {
$.loader('close');
}
});
},
minLength : 0,
open : function() {
$(this).removeClass(
"ui-corner-all").addClass(
"ui-corner-top");
},
close : function() {
$(this).removeClass(
"ui-corner-top").addClass(
"ui-corner-all");
},
select : function(event, ui) {
searchById(ui.item.value);
}
});
最佳答案
最简单的方法是限制源中返回结果的数量。
因此,在 getiId.html
中,将项目数限制为 10
关于jquery-ui - jquery 自动完成限制结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8921269/