Skip to content

Commit

Permalink
Autocomplete: Update cursor position in multiple demos in IE. Fixes #…
Browse files Browse the repository at this point in the history
…5761 - Autocomplete: multiple demos need extra IE handling for cursor position
  • Loading branch information
jzaefferer committed Jun 23, 2010
1 parent 496b408 commit 965dddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions demos/autocomplete/multiple-remote.html
Expand Up @@ -45,6 +45,13 @@
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
if ( document.selection ) {
this.focus();
var range = document.selection.createRange();
range.moveStart( 'character', this.value.length );
range.moveEnd( 'character', 0 );
range.select();
}
return false;
}
});
Expand Down
7 changes: 7 additions & 0 deletions demos/autocomplete/multiple.html
Expand Up @@ -39,6 +39,13 @@
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
if ( document.selection ) {
this.focus();
var range = document.selection.createRange();
range.moveStart( 'character', this.value.length );
range.moveEnd( 'character', 0 );
range.select();
}
return false;
}
});
Expand Down

1 comment on commit 965dddd

@Smssyed8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document.selection is coming undefined for me.
Please let me know if there is any way to set value returned from select function in autocomplete to current cursor position in textarea

Please sign in to comment.