Contact Us
+1.831.460.7010

There appears to be a flaw in the JQuery UI Spinner widget (version 1.10.3, July 2013).  http://api.jqueryui.com/spinner/

The problem is that the value actually displayed is different than the value that has been set.  The value displayed is affected by the "min" and "step" values.

This note explains the issue in more detail and points out an undocumented requirement for use of the widget.

There appears to be a flaw in the JQuery UI Spinner widget (version 1.10.3, July 2013).  http://api.jqueryui.com/spinner/

The problem is that the value actually displayed is different than the value that has been set.  The value displayed is affected by the "min" and "step" values.

We have constructed an example page to demonstrate the problem.  This page may be seen at http://iwl.com/tech_examples/spin-widget-july252013.html

In that example a spinner widget is initialized to a value, but the displayed value is altered by the "min" setting.

<input id="testspinnerA" name="testspinnera" style="width:14ex;"/>
$("#testspinnerA")
  .spinner(
    {numberFormat:"d", min:567, max:10000000000, step:100000, page:100,
     incremental:false
    })
  .spinner("value",4400000);
 

Update:

Apparently there is an undocumented requirement that the "min" value be zero or that its absolute value be an integral multiple of the "step" value.  This requirement is documented neither in the API documentation nor in the source code.

The value displayed in the spinner widget may be mis-displayed if this undocumented requirement is not met.  For some incomprehensible reason the jQuery-UI support team flippantly dismisses this as a non-problem.

This problem renders the jQuery-UI Spinner Widget difficult to use in some situations, particularly those where the desired "step" value is greater than the "min".

For example, consider an application in which the developer needs to spin through a range values that has a low minimum and a very high maximum.  This is illustrated by an example where the minimum is several decimal orders of magnitude smaller than the maximum.  For instance consider a spinner of bit-per-second rates that ranges from a few kilobits/second up through several gigabits/second.  The current design of jQuery Spinner means that the "step" would be constrained to be no more then that relatively tiny minimum.

One might excuse the jQuery-UI spinner code as merely inadequate for imposing such a requirement.  However, the jQuery-UI spinner code goes further and often displays a value different than what the application writer sent to the widget.

The jQuery-UI package is widely used.  Yet given that it can display incorrect values one must ask "is jQuery-UI safe to use" in a critical application?