From jQuery JavaScript Library
« 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:| Name | Type |
| currency | Boolean, String | Default: false
|
|---|
| Accepts a currency symbol, e.g. £. Will also automatically format into a currency value. |
| decimals | Number | Default: 0
|
|---|
| The number of decimal places displayed. |
| format | String | Default: "%"
|
|---|
| printf style formatting with named arguments, e.g. %(name), for customising the display value. Used for DOM lists only. See items. |
| group | String | Default: ""
|
|---|
| The symbol to use as a thousand separator / digital group separator. |
| incremental | Boolean | Default: true
|
|---|
| If incremental is set to true stepping delta will increase when spun incessantly. i.e. spinning jumps up a notch at set increments. |
| items | Array | |
|---|
| An Array of objects which automatically convert into DOM lists to form spinner items. Used in combination with format. |
| max | Number | |
|---|
| The upper limit. |
| min | Number | |
|---|
| The lower limit. |
| point | String | Default: '.'
|
|---|
| The symbol to use as a decimal point. |
| start | Number | Default: 0
|
|---|
| The default/start position. |
| stepping | Number | Default: 1
|
|---|
| The unit step size. |
| init | Function | |
|---|
| Callback triggered when the spinner initializes. |
| up | Function | |
|---|
| Callback function triggered when the spinner increments. |
| down | Function | |
|---|
| Callback function triggered when the spinner decrements. |
| spin | Function | |
|---|
| Callback function triggered when the spinner spins. |
| change | Function | |
|---|
| 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").
spinner( "enable" )
Enables the spinner.
This method re-enables a previously disabled spinner.
spinner( "destroy" )
Completely remove the spinner.
This method removes the spinner completely.