Browse Source

event fixes - previous problem was causes by another plugin (datepicker)=> partial revert

Robin Herbots 15 years ago
parent
commit
0ac9724df9
1 changed files with 17 additions and 6 deletions
  1. 17 6
      jquery.inputmask.js

+ 17 - 6
jquery.inputmask.js

@@ -293,14 +293,21 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
                         writeBuffer(input, buffer);
                         writeBuffer(input, buffer);
                     }
                     }
                 }).bind("blur.inputmask", function() {
                 }).bind("blur.inputmask", function() {
-                    if (_val.call(input) != undoBuffer) {
+                    input.removeClass('focus.inputmask');
+                    setTimeout(function() {
                         checkVal(input, buffer, true);
                         checkVal(input, buffer, true);
-                        input.change();
-                    }
-                }).bind("click.inputmask", function() {
+                        if (_val.call(input) == _buffer.join(''))
+                            _val.call(input, '');
+                        else if (_val.call(input) != undoBuffer) {
+                            input.change();
+                        }
+                    }, 0);
+                }).bind("focus.inputmask", function() {
                     input.addClass('focus.inputmask');
                     input.addClass('focus.inputmask');
                     undoBuffer = _val.call(input);
                     undoBuffer = _val.call(input);
-                    caret(input, checkVal(input, buffer, true));
+                    setTimeout(function() {
+                        caret(input, checkVal(input, buffer, true));
+                    }, 0);
                 }).bind("mouseleave.inputmask", function() {
                 }).bind("mouseleave.inputmask", function() {
                     if (!input.hasClass('focus.inputmask') && _val.call(input) == _buffer.join(''))
                     if (!input.hasClass('focus.inputmask') && _val.call(input) == _buffer.join(''))
                         _val.call(input, '');
                         _val.call(input, '');
@@ -311,7 +318,11 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
                         caret(input, checkVal(input, buffer, true));
                         caret(input, checkVal(input, buffer, true));
                     }, 0);
                     }, 0);
                 }).bind('setvalue.inputmask', function() {
                 }).bind('setvalue.inputmask', function() {
-                    checkVal(input, buffer, true);
+                    setTimeout(function() {
+                        checkVal(input, buffer, true);
+                        if (_val.call(input) == _buffer.join(''))
+                            _val.call(input, '');
+                    }, 0);
                 });
                 });
 
 
             }
             }