我正在使用JQuery 1.8.3和JQuery UI 1.8.24.
这是代码,工作得很好:
$(function () {
$("#").autocomplete({
source: function (request, response) {
$.ajax({
url: '', type: "POST", dataType: "json",
data: { searchPattern: request.term },
cache: false,
success: function (data) {
response($.map(data, function (item) {
return { label: item.Label, value: item.Value, id: item.Id, description: item.Description }
}))
}
});
},
delay: 300,
minLength: 2,
autoFocus: true
})
.data("autocomplete")._renderItem = function (ul, item) {
return $("li>/li>")
.data("ui-autocomplete-item", item)
.append("a>" + item.label + "br>div style=\"font-size:x-small;font-style:italic;\">" + …Run Code Online (Sandbox Code Playgroud)