限制 Jquery UI 自动完成的结果
Limiting results of Jquery UI autocomplete
我想问一下,如何限制搜索结果。
这是一段代码,负责查询。
我只想有五个自动完成项目。
来源:
function( request, response ) {
$.ajax({
type : 'post',
dataType: "json",
data: {
'person':request
},
url: 'PersonWatch/all',
success: function(data) {
response( $.map( data, function(item, i) {
return item.person
}));
}
});
}
尝试
response($.map(data, function(item, i) {
return i < 5 ? item.person : null
})
);
我想问一下,如何限制搜索结果。 这是一段代码,负责查询。 我只想有五个自动完成项目。
来源:
function( request, response ) {
$.ajax({
type : 'post',
dataType: "json",
data: {
'person':request
},
url: 'PersonWatch/all',
success: function(data) {
response( $.map( data, function(item, i) {
return item.person
}));
}
});
}
尝试
response($.map(data, function(item, i) {
return i < 5 ? item.person : null
})
);