$("#users-allowed").autocomplete("/people/following.json", {
width: 320,
dataType: 'json',
highlight: false,
scroll: true,
scrollHeight: 300,
parse: function(data) {
var array = new Array();
for(var i=0;i<data.items.length;i++) {
array[array.length] = { data: data.items[i], value: data.items[i], result: data.items[i].username };
}
return array;
},
formatItem: function(row) {
var name = '';
if (row.first_name && row.last_name)
name = '('+row.first_name+', '+row.last_name+')';
else if (row.first_name)
name = '('+row.first_name+')';
else if (row.last_name)
name = '('+row.last_name+')';
return row.username+' '+name;
}
});
check dataType and parse option.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…