Reputation: 6389
I have just implemented the excellent jQuery UI autocomplete.
http://jqueryui.com/demos/autocomplete/
There is a strange bug in IE 8 (and maybe other versions).
When you select an item from the box of suggestions in IE 8 the cursor moves to the begining of the textbox before the suggested word which has just been inserted.
Firefox put the cursor after the inserted word.
Does anyone know of a fix for this?
Regards
Steve
Upvotes: 0
Views: 3077
Reputation: 34347
Try adding the following code into the select event that is passed to the autocomplte function.
So if you have:
jQuery('someval').autocomplete({
source: availableTags
});
Change it to be:
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();
}
}
})
See more: http://forum.jquery.com/topic/ui-autocomplete-multiple-demo-caret-position-in-ie http://jqueryui.com/demos/autocomplete/#multiple
Upvotes: 1