我正在尝试使用此类型前导代码http://www.runningcoder.org/jquerytypeahead/demo/
但我无法理解这些例子。
服务器响应:
{
cities: [{
id: id
name: name
},
{
id: id2,
name: name2
}]
}
这是js
$(function(){
$.typeahead({
input: '#hotel-city-autocomplete',
minLength: 2,
maxItem: 5,
order: "asc",
template: "{{display}} <small style='color:#999;'>{{group}}</small>",
source: {
city: {
ajax: {
url: '/cities.json',
path: 'data.cities'
}
}
},
callback: {
onResult: function (node, query, result, resultCount) {
}
}
});
});
它不起作用。如何修复它?我想在下拉列表和输入中显示名称并将ID作为值。