Browse Source

make mobileinput event more reliable

Robin Herbots 12 years ago
parent
commit
6e0b298255
1 changed files with 4 additions and 6 deletions
  1. 4 6
      js/jquery.inputmask.js

+ 4 - 6
js/jquery.inputmask.js

@@ -1192,19 +1192,17 @@
                 var caretPos = caret(input),
                 var caretPos = caret(input),
                     currentValue = input._valueGet();
                     currentValue = input._valueGet();
 
 
-                if (currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin]
+                if ((getActiveBuffer().length - currentValue.length) == 1 && currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin]
                     && currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin]
                     && currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin]
                     && !isMask(caretPos.begin)) {
                     && !isMask(caretPos.begin)) {
                     e.keyCode = opts.keyCode.BACKSPACE;
                     e.keyCode = opts.keyCode.BACKSPACE;
                     keydownEvent.call(input, e);
                     keydownEvent.call(input, e);
                 } else { //nonnumerics don't fire keypress 
                 } else { //nonnumerics don't fire keypress 
                     checkVal(input, false, false);
                     checkVal(input, false, false);
-                    writeBuffer(input, getActiveBuffer());
+                    writeBuffer(input, getActiveBuffer(), seekNext(caretPos.begin - 1));
                     if (isComplete(getActiveBuffer()) === true)
                     if (isComplete(getActiveBuffer()) === true)
                         $input.trigger("complete");
                         $input.trigger("complete");
-                    $input.click();
                 }
                 }
-                e.preventDefault();
             }
             }
 
 
             function mask(el) {
             function mask(el) {
@@ -1362,8 +1360,8 @@
                         setTimeout(function () {
                         setTimeout(function () {
                             caret(input, 0, seekNext(getActiveMaskSet()["lastValidPosition"]));
                             caret(input, 0, seekNext(getActiveMaskSet()["lastValidPosition"]));
                         }, 0);
                         }, 0);
-                    }).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
-                    ).bind('setvalue.inputmask', function () {
+                        //}).bind(PasteEventType + ".inputmask dragdrop.inputmask drop.inputmask", pasteEvent
+                    }).bind('setvalue.inputmask', function () {
                         var input = this;
                         var input = this;
                         checkVal(input, true);
                         checkVal(input, true);
                         valueOnFocus = getActiveBuffer().join('');
                         valueOnFocus = getActiveBuffer().join('');