jqueryオートコンプリートを使用して、GeoNamesからページのテキストボックスに都市をロードしています。
$("#MyInput").autocomplete({
source: function (request, response) {
$.ajax({
url: "http://ws.geonames.org/searchJSON",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 10,
name_startsWith: request.term
},
success: function (data) {
response($.map(data.geonames, function (item) {
return {
label: item.name + ", " + item.countryName,
value: item.name + " (" + item.countryName + ")" + " [" + item.countryCode + "]"
};
}));
}
});
}
}).data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><strong>" + item.label + "</strong> / " + item.value + "</a>")
.appendTo(ul);
};
また、_renderItemをオーバーライドして、オートコンプリートの結果をカスタムビューに表示しようとしていますが、このメソッドはアイテムに影響しません。私のコードの何が問題になっていますか?jsfiddle.net/で例を見つけることができます