浏览代码

Fix focus detection when applying mask or reapplying

Robin Herbots 14 年之前
父节点
当前提交
ec150283ae
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      jquery.inputmask.js

+ 5 - 2
jquery.inputmask.js

@@ -3,7 +3,7 @@ Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 0.4.2b
+Version: 0.4.2c
  
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 */
@@ -559,9 +559,12 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
                 }
 
                 setTimeout(function() {
-                    caret(input, checkVal(input, buffer, true));
+                    lastPosition = checkVal(input, buffer, true);
                     if (opts.clearMaskOnLostFocus && _val.call(input) == _buffer.join(''))
                         _val.call(input, '');
+                    if(document.activeElement === input[0]) { //position the caret when in focus
+                    	caret(input, lastPosition);
+                    }
                 }, 0);
 
                 //private functions