concept control in category javascript

appears as: control, controls, control, controls
Prototype and Scriptaculous in Action

This is an excerpt from Manning's book Prototype and Scriptaculous in Action.

In many scripting languages, such as Ruby, Python, and Visual Basic, it’s possible to provide named arguments to a function. This can be helpful if a function is capable of accepting a wide range of arguments but will generally be called with only one or two. Named arguments allow a function to provide sensible defaults for the casual user, and a fine degree of control for the power user.

To help you style the contents of the form created while the control is in active mode, Scriptaculous assigns a class name of inplaceeditor-form to the form. The formClassName option can be used to specify a different class name for the form.

Now let’s see what our controls are doing, so that we can react appropriately to the various state changes that the controls will go through as they are used on the page.

Table 6.5. The Control.Slider options

Option

Description

axis The orientation of the control, which can be set to horizontal or vertical. The default orientation is horizontal.
range The range of the slider values, defined as an instance of a Prototype ObjectRange instance. Defaults to 0 through 1.
values The discrete set of values that the slider can acquire. If omitted, all values within the range can be set.
sliderValue The initial value of the slider. If omitted, the value represented by the left-most (or top-most) edge of the slider is the initial value.
disabled A Boolean value that specifies whether the slide is initially disabled. Defaults to false (not disabled).
onChange Callback invoked when the slider value changes.
onSlide Callback invoked when the handle is being dragged.

If we wanted to set up a slider such that the range of values spans from 1 at the left end of the control to 100 at the right end, we would specify the range option as follows:

range: $R(1,100)

If we could see the values that the slider was acquiring (patience, that’s coming up next), we’d notice that the slider acquires not only integer values, but also all real values within the range. If we move the handle to about what we think is the middle of a control with a range of 1 through 100, we might expect the value to be 50, but instead we may find that the value is 48.7573572347. If we want to specify the discrete values within the range that the slider should acquire, we can do that with the values option.