我已经填充自动完成的单词,我想在单词之间有一个行分隔符,以便在自动完成中更好地识别。 说,在下拉值应该呈现为自动完成JQuery行分隔符
Brijesh
-------
John
-------
Mike
下面是摘录
$(document).ready(function() {
$("#studentName").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Webservice.asmx/GetStudentNames",
data: "{'prefixText':'" + request.term + "'}",
dataType: "json",
success: function (data) {
var regex = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + request.term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi");
response($.map(data.d, function (item) {
return {
label: item.split('|')[0].replace(regex, "<Strong>$1</Strong>"),
val: item.split('|')[1]
}
}))
},
failure: function (response) {
ServiceFailed(result);
}
});
},
select: function (event, ui) {
txtStudent(ui.item.val, ui.item.label); //Student name and id used in this method
},
minLength: 2
});
});
任何线索,将不胜感激。
CSS将在这里得到较好的解决IMO,而不是追加 '不可选择' 的选项。只需添加'border-bottom:1px solid#000; margin:5px 0;'给下拉列表中的每个元素。 – 2012-03-28 11:04:24