1
0
mirror of synced 2024-11-26 23:06:02 +03:00

fix fast typing in IE. fixes #949

This commit is contained in:
Igor Vaynberg 2013-05-06 20:54:01 -07:00
parent 26f41602b2
commit 694432d83d

View File

@ -1716,11 +1716,24 @@ the specific language governing permissions and limitations under the Apache Lic
// single // single
opening: function () { opening: function () {
var el, range;
this.parent.opening.apply(this, arguments); this.parent.opening.apply(this, arguments);
if (this.showSearchInput !== false) { if (this.showSearchInput !== false) {
// IE appends focusser.val() at the end of field :/ so we manually insert it at the beginning using a range
// all other browsers handle this just fine
this.search.val(this.focusser.val()); this.search.val(this.focusser.val());
} }
this.search.focus(); this.search.focus();
// in IE we have to move the cursor to the end after focussing, otherwise it will be at the beginning and
// new text will appear *before* focusser.val()
el = this.search.get(0);
if (el.createTextRange) {
range = el.createTextRange();
range.collapse(false);
range.select();
}
this.focusser.prop("disabled", true).val(""); this.focusser.prop("disabled", true).val("");
this.updateResults(true); this.updateResults(true);
this.opts.element.trigger($.Event("select2-open")); this.opts.element.trigger($.Event("select2-open"));