我在我的contenteditable div上有一个JQuery Autocomplete,它正在使用英语。但是当我试图用其他语言(即俄语)输入时,它甚至不会触发源操作符。
$this.autocomplete({
position: { my : "right top", at: "right bottom" },
source: function(request, response) {
var str = _leftMatch(request.term.trim(), $("#tags")[0]);
// console.log(str);
str = (str != null) ? str[0] : "";
response($.ui.autocomplete.filter(
cities, str));
},
focus: function() {
return false;
},
select: function(event, ui) {
// alert("completing "+ui.item.value);
var m = _leftMatch($(this).clone().children().remove().end().text().trim(), this)[0];
var beg = $(this).clone().children().remove().end().text().trim().substring(0, this.selectionStart - m.length);
var children = $(this).children();
var txt = ui.item.value;
$(this).html("");
var mark = $(markTag);
mark.children('span').text(txt);
$(this).append(children);
$(this).append(mark);
placeCaretAtEnd($(this)[0]);
return false;
},
search:function(event, ui) {
var m = _leftMatch($(this).clone().children().remove().end().text().trim(), this);
return (m != null )
},
open: function (event, ui) {
var cordinates = getSelectionCoords();
var top = cordinates.y +30 + "px";
$(this).autocomplete("widget").css({
"width": ("auto"),
"top": top,
"left": cordinates.x
});
}
});
这是_leftMatch函数
function _leftMatch(string, area) return string.substring(0, area.selectionStart).match(/[\wäöüÄÖÜß]+$/);