0
在我的代码我使用下面,来格式化我的自动完成结果:jQuery UI - 自动完成 - 条件renderitem?
$.ui.autocomplete.prototype._renderItem = function (ul, item) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(this.term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("custom strong goes here....")
.appendTo(ul);
};
我有一个autocompelte场:
$("#autoSearch").autocomplete({
source: function(request, response) {
$.ajax({
url: "index.pl",
dataType: "json",
data: {
term: request.term
},
success: function(data) {
response($.map(data.items, function(item) {
return {
itemclass: item.itemclass,
label: "<B>" + item.id + "</b><br>" + item.label,
value: item.id
}
));
}
});
},
minLength: 2
});
现在我想添加一个自动完成场,但我不不想将渲染项目应用到它。我如何添加一个选择器的renderitem声明,或者我可以在上面的autoSearch代码中以某种方式包含它?