<script>
$(function() {
$( "#currency" ).change(function() {
- var current = $( "#spinner" ).spinner( "value" );
- Globalize.culture( $(this).val() );
- $( "#spinner" ).spinner( "value", current );
+ $( "#spinner" ).spinner( "option", "culture", $( this ).val() );
});
$( "#spinner" ).spinner({
equal( element.val(), "$1.00", "formatted after step" );
});
+test( "numberFormat, change", function() {
+ expect( 2 );
+ var element = $( "#spin" ).val( 5 ).spinner({ numberFormat: "n1" });
+ equal( element.val(), "5.0", "formatted on init" );
+ element.spinner( "option", "numberFormat", "c" );
+ equal( element.val(), "$5.00", "formatted after change" );
+});
+
test( "culture, null", function() {
expect( 2 );
Globalize.culture( "ja-JP" );
equal( element.val(), "¥1", "formatted after step" );
});
+test( "currency, change", function() {
+ expect( 2 );
+ var element = $( "#spin" ).val( 5 ).spinner({
+ numberFormat: "C",
+ culture: "ja-JP"
+ });
+ equal( element.val(), "¥5", "formatted on init" );
+ element.spinner( "option", "culture", "en" );
+ equal( element.val(), "$5.00", "formatted after change" );
+});
+
test( "max", function() {
expect( 3 );
var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
},
_setOption: function( key, value ) {
+ if ( key === "culture" || key === "numberFormat" ) {
+ var prevValue = this._parse( this.element.val() );
+ this.options[ key ] = value;
+ this.element.val( this._format( prevValue ) );
+ return;
+ }
+
this._super( "_setOption", key, value );
if ( key === "disabled" ) {