我正在尝试使用Easy AutoComplete(http://easyautocomplete.com)进行搜索下拉菜单。这是我的代码,它显示的是基于从url返回的数据的列表,但是当我点击一个选项时,我得到两个错误:
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
at HTMLInputElement.<anonymous> (jquery.easy-autocomplete.min.js?body=1:11)
at HTMLInputElement.dispatch (jquery.js?body=1:4625)
at HTMLInputElement.elemData.handle (jquery.js?body=1:4293)
at Object.trigger (jquery.js?body=1:4534)
at Object.simulate (jquery.js?body=1:4860)
at HTMLDocument.handler (jquery.js?body=1:5116)
和
GET http://conductor.dev/admin/customers/d/addresses.json 404 (Not Found)
我不想在单击选项时发出任何get请求,我只想将textfield的值作为id。这是我的代码:
var options = {
url: function(phrase) {
return "/admin/customers.json?query=" + phrase;
},
listLocation: "customers",
getValue: "id",
template: {
type: "custom",
method: function(value, item) {
return item.customers.last_name +","+ item.customers.first_name
}
}
};
$('#appointment_customer_id').easyAutocomplete(options);