A slider is a scale with a handle you can drag up/down or left/right to select a value. Calling dojo.require("dijit.form.Slider") provides dijit.form.HorizontalSlider, dijit.form.VerticalSlider and all the rule and label classes.
One way you could show the user the value of your Slider is to create a textbox that the Slider fills when the user moves the Slider. The following code fills in a simple textbox called horizontalSliderValue.
You can point the handleSrc image to wherever you want. If you want to use the default handle image, just remove the handleSrc.
For a horizontal slider, you can use the HorizintalRule and HorizontalRuleLabels to create your ruler marks programmatically, reducing the amount of data being transferred over the wire:
The VerticalSlider API is identical to the HorizontalSlider API. You can use the VerticalRule class to create vertical ruler marks.
|
dijit.form.HorizontalSlider, dijit.form.VerticalSlider
A form widget that allows one to select a value with a horizontally (or vertically) draggable image
|
||
|
Attributes
|
||
| clickSelect | boolean true |
If clicking the progress bar changes the value or not |
| discreteValues | integer Infinity |
The maximum allowed values dispersed evenly between minimum and maximum (inclusive). |
| intermediateChanges | Boolean false |
If true, trigger an onChange event every time setValue is called. If false, trigger onChange only when asked by the callee. For example, on Slider a true value would fire onChange events at each point of the mouse drag. False would trigger onChange only on mouseUp. |
| maximum | integer 100 |
The maximum allowed value. |
| minimum | integer 0 |
The minimum value allowed. |
| pageIncrement | integer 2 |
The amount of change with pageup/pagedown |
| showButtons | boolean true |
Show increment/decrement buttons at the ends of the slider? |
|
Methods
|
||
| setValue((/*Number*/ value, /*Boolean, optional*/ priorityChange) | Regular setValue, but if priorityChange is true, then it is more likely to be animated. | |
|
dijit.form.HorizontalRule, dijit.form.VerticalRule
Create hash marks for the Horizontal/Vertical slider
|
||
|
Attributes
|
||
| container | Node containerNode |
If this is a child widget, connect it to this parent node |
| count | Integer 3 |
Number of hash marks to generate |
| ruleStyle | String | CSS style to apply to individual hash marks |
|
dijit.form.HorizontalRuleLabels, dijit.form.VerticalRuleLabels
Create labels for the Slider
|
||
|
Attributes
|
||
| labels | Array [] |
Array of text labels to render - evenly spaced from left-to-right or bottom-to-top |
| labelStyle | String | CSS style to apply to individual text labels |
| Action | Key |
|---|---|
| Interact with the slider | The slider handle is in the tab order of the page. Press tab key to set focus to the slider handle. |
| Increase slider value by single increment | With focus on slider handle press right or up arrow |
| Decrease slider value by single increment | With focus on slider handle press left or down arrow |
| Increase slider value by multiple increments | With focus on slider handle press pageup. The amount of increment is determined by the pageIncrement parameter |
| Decrease slider value by multiple increments | With focus on slider handle press pagedown. The amount of increment is determined by the pageIncrement parameter |
| Set slider to minimum value | With focus on slider handle press home. |
| Set slider to maximum value | With focus on slider handle press end. |
Currently the text labels of a slider are not spoken by screen readers. Firefox 3 will support this type of labeling so the plan is to add support for it in the Dojo 1.2 release. Developers should take care when using text labels since a screen reader user will hear only a numeric interpretation.