From 31ebe7e7da7d7ce737a1feb3b19dec047e88a3a5 Mon Sep 17 00:00:00 2001 From: Scott González Date: Sat, 7 Jan 2012 09:12:27 -0500 Subject: Spinner: Allow strings for min, max, and step options, converting immediately to numbers based on numberFormat and culture. --- ui/jquery.ui.spinner.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ui') diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index b78b4dbea..c99520b7c 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -45,7 +45,14 @@ $.widget( "ui.spinner", { }, _create: function() { + // handle string values that need to be parsed + this._setOption( "max", this.options.max ); + this._setOption( "min", this.options.min ); + this._setOption( "step", this.options.step ); + + // format the value, but don't constrain this._value( this.element.val(), true ); + this._draw(); this._bind( this._events ); this._refresh(); @@ -318,6 +325,12 @@ $.widget( "ui.spinner", { return; } + if ( key === "max" || key === "min" || key === "step" ) { + if ( typeof value === "string" ) { + value = this._parse( value ); + } + } + this._super( key, value ); if ( key === "disabled" ) { -- cgit v1.2.3