Documentation

UI/Spinner/spinner

From jQuery JavaScript Library

Jump to: navigation, search

« Back to UI/Spinner

spinner[options] )

Creates a Spinner widget.
This jQuery widget turns input fields or DOM nodes into a spin button. Handles such as min, max and currency provided.

Callbacks (init, up, down, spin, change) accept two arguments: The original browser event and a prepared ui object. The ui object have these fields:

  • ui.element - a jQuery object containing the spinner element.
  • ui.options - options used to initialize the spinner.
  • ui.value - current value of the spinner.
  • ui.add - add a new item to the spinner (DOM nodes only).
Arguments:
options (Optional)Options
A set of key/value pairs that configure the spinner. All options are optional.


Options:

NameType
currencyBoolean, StringDefault: false
Accepts a currency symbol, e.g. £. Will also automatically format into a currency value.
decimalsNumberDefault: 0
The number of decimal places displayed.
formatStringDefault: "%"
printf style formatting with named arguments, e.g. %(name), for customising the display value. Used for DOM lists only. See items.
groupStringDefault: ""
The symbol to use as a thousand separator / digital group separator.
incrementalBooleanDefault: true
If incremental is set to true stepping delta will increase when spun incessantly. i.e. spinning jumps up a notch at set increments.
itemsArray
An Array of objects which automatically convert into DOM lists to form spinner items. Used in combination with format.
maxNumber
The upper limit.
minNumber
The lower limit.
pointStringDefault: '.'
The symbol to use as a decimal point.
startNumberDefault: 0
The default/start position.
steppingNumberDefault: 1
The unit step size.
initFunction
Callback triggered when the spinner initializes.
upFunction
Callback function triggered when the spinner increments.
downFunction
Callback function triggered when the spinner decrements.
spinFunction
Callback function triggered when the spinner spins.
changeFunction
Callback function triggered when the value is changed.


spinner( "disable" )

Temporarily disables the spinner.
This method temporarily disables the spinner. It can later be reenabled by calling $(..).spinner("enable").
Arguments:
"disable"String

spinner( "enable" )

Enables the spinner.
This method re-enables a previously disabled spinner.
Arguments:
"enable"String

spinner( "destroy" )

Completely remove the spinner.
This method removes the spinner completely.
Arguments:
"destroy"String