jQuery UI无法使用外部JSON文件进行筛选-列出所有项目
My ext.JSON(无法编辑): 我的jQueryUI自动完成:jQuery UI无法使用外部JSON文件进行筛选-列出所有项目,json,jquery-ui,filter,external,Json,Jquery Ui,Filter,External,My ext.JSON(无法编辑): 我的jQueryUI自动完成: $('.tables .new_bill .client').autocomplete({ source: function (request, response) { $.getJSON("data/clients.json", function (data) { response($.map(data, function (item) { re
$('.tables .new_bill .client').autocomplete({
source: function (request, response) {
$.getJSON("data/clients.json", function (data) {
response($.map(data, function (item) {
return {
label: item.name,
value: item.name,
pic: item.pic
};
}));
response($.ui.autocomplete.filter(array, request.term));
});
},
minLength: 0,
});
无论我键入什么,都会在“自动完成”下拉列表中获得我的ext JSON对象的完整列表…我发现:
$.getJSON("data/clients.json", function (data) {
clients=data;
var clients_ar=[];
$.each(data, function(k,v) {
var client=[];
client['label']=v.name;
client['value']=v.name;
client['pic']=v.pic;
client['id']=k;
clients_ar.push(client);
});
$('.tables .new_bill .client').autocomplete({
source: clients_ar,
minLength: 0,
select: function(event, ui) {
var client_id=ui.item.id;
var client_photo=ui.item.pic;
....................................
}
});
});
$.getJSON("data/clients.json", function (data) {
clients=data;
var clients_ar=[];
$.each(data, function(k,v) {
var client=[];
client['label']=v.name;
client['value']=v.name;
client['pic']=v.pic;
client['id']=k;
clients_ar.push(client);
});
$('.tables .new_bill .client').autocomplete({
source: clients_ar,
minLength: 0,
select: function(event, ui) {
var client_id=ui.item.id;
var client_photo=ui.item.pic;
....................................
}
});
});