我使用这个函数将 jquery ui 自动完成函数的结果包装在一个超链接中。它无法做到这一点。它只显示标签项。这里有什么建议吗?
[{"value":"morzine","label":"Morzine"},{"value":"grachen","label":"Grachen"},{"value":"fiesch","label":"Fiesch"},{"value":"zermatt","label":"Zermatt"},{"value":"saas-fee","label":"Saas Fee"},{"value":"bettmeralp","label":"Bettmeralp"},{"value":"riederalp","label":"Riederalp"},{"value":"jeizinen","label":"Jeizinen"},{"value":"crans-montana","label":"Crans Montana"},{"value":"simplon-dorf","label":"Simplon Dorf"}]
$("#srch").autocomplete({
minLength: 3,
source: function (a, b) {
$.getJSON("http://skiweather.eu/v3/ajax/search.php?q=" + a.term + "&format=json", function (a) {
b(a)
})
},
select: function (a, b) {
$("#srch").val(b.item.label);
return false
},
focus: function (a, b) {
$("#srch").val(b.item.label);
return false
}
}).data("autocomplete")._renderItem = function (a, b) {
return $("<li></li>")
.data("item.autocomplete", b)
.append('<a href="/webcams/' + b.value + '"> ' + b.label + '</a> ')
.appendTo(a)
}