Typing problem with jquery UI Autocomplete
I have problem with jquery ui Autocomplete... when i start typing words and while autocomplete is showing the results it just starts erasing letters before I even finish the word... anyone had this problem?
$(function() {
var rn = Math.floor(Math.random() * 11);
$("#query").autocomplete({开发者_开发百科
source: "search.asp?rn=" + rn,
minLength: 2,
selectFirst: true,
delay: 500,
//autoFocus: true,
select: function(event, ui) {
var vp = ui.item.vp;
var ran = Math.floor(Math.random() * 11);
if (vp != "-1" && vp != "x") {
location.href = "menu.asp?rn=" + ran + "&LOC=1&IDP=" + vp;
}
else if (vp == 'x') {
location.href = "result.asp?rn=" + ran + "&term=" + ui.item.value;
}
}
});
$.ui.autocomplete.prototype._renderItem = function(ul, item) {
var sterm = this.term.split(" ");
$.each(sterm, function(index, value) {
item.label = item.label.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + $.ui.autocomplete.escapeRegex(value) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<span style='color: #2779AA;'><strong>$1</strong></span>");
});
return $("<li></li>").data("item.autocomplete", item).append("<a>" + item.label + "</a>").appendTo(ul);
};
});
Are you using the autoFocus plugin? I had the same problem and fixed it with the solution described in:
https://github.com/scottgonzalez/jquery-ui-extensions/issues/1
精彩评论