Reputation: 153
In autocomplete property select I can't insert the selected value to the input text. Even using $(this)
and $(#inputname)
still does't work.
What am I doing wrong?
$(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);
}
});
Here is a jsfiddle
Upvotes: 1
Views: 151