Skip to content

Commit

Permalink
fixed issue on IE: selecting flag puts cursor at beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Feb 23, 2014
1 parent 7f7cf53 commit 4106b7d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ Plugin.prototype = {
if (!that.telInput.is(":focus") && !that.telInput.val()) {
e.preventDefault();
// but this also cancels the focus, so we must trigger that manually
that.telInput.focus();
that._putCursorAtEnd();
that._focus();
}
});
// on focus: if empty, insert the dial code for the currently selected flag
Expand All @@ -221,8 +220,9 @@ Plugin.prototype = {
}
});
},
// put the cursor at the end of the input
_putCursorAtEnd: function() {
// focus input and put the cursor at the end
_focus: function() {
this.telInput.focus();
var input = this.telInput[0];
// works for Chrome, FF, Safari, IE9+
if (input.setSelectionRange) {
Expand Down Expand Up @@ -393,7 +393,7 @@ Plugin.prototype = {
this.telInput.val(newNumber);
this.telInput.trigger("change");
// focus the input
this.telInput.focus();
this._focus();
},
// close the dropdown and unbind any listeners
_closeDropdown: function() {
Expand Down
Loading

0 comments on commit 4106b7d

Please sign in to comment.