0
내 페이지에있는 텍스트 상자에 GeoNames을에서 도시를로드 할 JQuery와 자동 완성을 사용하고
: 또한jquery ui 자동 완성 항목을 재정의하는 방법은 무엇입니까?
$("#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/
데모가 제대로 작동하고 제대로 된 것 같습니다. 문제가 무엇입니까? – charlietfl