我刚刚实现了优秀的jQuery UI自动完成功能。
http://jqueryui.com/demos/autocomplete/
IE 8中有一个奇怪的错误(可能还有其他版本)。
当您从IE 8中的建议框中选择一个项目时,光标将移动到刚刚插入的建议单词之前的文本框的开头。
Firefox将光标放在插入的单词后面。
有没有人知道修复此问题?
此致
史蒂夫答案 0 :(得分:1)
尝试将以下代码添加到传递给autocomplte函数的select事件中。
所以如果你有:
jQuery('someval').autocomplete({
source: availableTags
});
将其更改为:
jQuery('some_val').autocomplete({
source: availableTags,
select : function(event, ui){
if(document.selection) {
this.focus();
var oSel = document.selection.createRange();
oSel.moveStart('character',this.value.length);
oSel.moveEnd('character',0);
oSel.select();
}
}
})
查看更多: http://forum.jquery.com/topic/ui-autocomplete-multiple-demo-caret-position-in-ie http://jqueryui.com/demos/autocomplete/#multiple
答案 1 :(得分:1)
http://bugs.jqueryui.com/ticket/6858 这个对我帮助很大!