Slider
While a slider may not be a native HTML form control, there can be little dispute about how useful sliders can be for highly visual interfaces. Whether your goal is to adjust the transparency for an image, adjust the amount of a particular color in a custom color combination, or resize some other control on the screen, a slider can help you do it in a very intuitive manner. Dijit offers both horizontal and vertical sliders.
Tip
The Slider dijit is an
especially slick piece of engineering. Like some of the other
dijits, it keeps track of the current value via a hidden form value
so that when you submit a form, the value is passed over to the
server just like any other form field.
To get all of the various Slider machinery into your page, simply do a
dojo.require("dijit.form.Slider").
In addition to VerticalSlider and
HorizontalSlider, you also get the
supporting classes for rules and labels. Let's start with something
simple and gradually add some complexity so that you get a better feel
for exactly how customizable this fantastic little widget really
is.
HorizontalSlider
Suppose that as a caffeine junkie, you want to create a
horizontal slider that denotes caffeine levels for various
beverages. Your first stab at getting a plain vanilla slider into
the page might be something like the Example 13-13, remembering to
first require dijit.form.Slider
into the page.
Example 13-13. HorizontalSlider (Take 1)
<div dojoType="dijit.form.HorizontalSlider" name="caffeine" value="100" maximum="175" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access