]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Don't clear invalid values on blur (but clear the value option).
authorScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 17:28:25 +0000 (13:28 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 17:28:25 +0000 (13:28 -0400)
ui/jquery.ui.spinner.js

index a8f3a4fe980d2b96f815f1acc5e33c1fcdc99235..baa3fb5cb4a71c6fe6fb2209c5c6dbb92964562a 100644 (file)
@@ -84,7 +84,13 @@ $.widget( "ui.spinner", {
                                uiSpinner.addClass( "ui-state-active" );
                        },
                        blur: function( event ) {
-                               this.value( this.element.val() );
+                               // don't clear invalid values on blur
+                               var value = this.element.val(),
+                                       parsed = this._parse( value );
+                               this.option( "value", parsed );
+                               if ( parsed === null ) {
+                                       this.element.val( value );
+                               }
                                // TODO: is this really correct or just the simplest
                                // way to keep the active class when pressing the buttons?
                                // if the mosue is over the text field and the user tabs out