0
아무도 도와 드릴 수 있습니까?Jquery 자동 완성 각 단어 첫 글자를 기준으로 검색
자동 완성은 문장의 각 단어의 첫 글자를 기반으로해야합니다. 예를
를 들어
내가
결과가 있어야한다 "S"를 찾고 있어요 경우 :
결과는 각 단어의 "S"첫 문자를 기반으로해야
http://i.stack.imgur.com/9H9ma.gif
문장에.도와주세요 ..
미리 감사드립니다.
는 시도 :
/* 자동 완성 강조 */
String.prototype.replaceAt = function(index, char) {
return this.substr(0, index) + "<span style='font-weight:bold;color:#333;'>" + char + "</span>";
}
$.ui.autocomplete.prototype._renderItem = function(ul, item) {
this.term = this.term.toLowerCase();
var resultStr = item.label.toLowerCase();
var t = "";
while (resultStr.indexOf(this.term) != -1) {
var index = resultStr.indexOf(this.term);
t = t + item.label.replaceAt(index, item.label.slice(index, index + this.term.length));
resultStr = resultStr.substr(index + this.term.length);
item.label = item.label.substr(index + this.term.length);
}
return $("<li></li>").data("item.autocomplete", item).append("<a style='padding:4px 4px; display:block; width:97.3%;'>" + t + item.label + "</a>").appendTo(ul);
};
/* Autocomplete highlighting Ends here*/
아래 코드로 시도했습니다. $ (document) .ready (function() { $ ("# 요청"). 자동 완료 ({ 소스 : 함수 (req, responseFn) { var re = $ .ui.autocomplete.escapeRegex (req.term); var matcher = new RegExp ("\\ b"+ re, "i"); var a = $ .grep (charity_names, function (item, index) { return matcher.시험 (항목); }}); responseFn (a); }, 지연 시간 : 0 }); }}); – Jagadeesh
백엔드 PHP, Java에서 무엇을 사용하고 있습니까 ?? – Zafta
Java 응용 프로그램에서,하지만 지금은 프로토 타입 디자인을위한 HTML 및 Jquery를 사용하고 있습니다. – Jagadeesh