在自动完成属性中,选择我无法将所选值插入输入文本。即使使用$(this)
和$(#inputname)
仍然无效。
我做错了什么?
$(document).ready(function () {
var strMe = {
"vntret": [
{ "e_city": "CITY1", "e_province": "PROVINCE1" },
{ "e_city": "CITY2", "e_province": "PROVINCE2" }
]
}
$("#txtAddressL2").autocomplete({
source: strMe,
source: function (request, response) {
//how to filtering just skipped
{
response(strMe.vntret);
}
},
minLength: 3,
select: function (event, ui) {
$(this).val(ui.item.e_city);
//event this command doesnt works as well
$("#txtAddressL2").val(ui.item.e_city);
}
}).data("ui-autocomplete")._renderItem = function (ul, item) {
return $("<li></li>").data("item.autocomplete", item)
.append("<a>" + item.e_city + "<br>" + item.e_province + "</a>")
.appendTo(ul);
}
});
这是jsfiddle