The Switch control allows the display of a binary value (similar to a checkbox) using an On/Off visual switch widget.
Like almost all SPARK controls, you can trigger events that are fired when the user interacts with the control (see the Event and Methods sections below and the Event Handling article for more information).
The Switch control should be bound to a Boolean variable.
Appearance
Color Style
Shape Style
Size Style Default, Large, Small
Label Type Allows the user to change the On/Off labels from text to icons.
On Label* The label/icon when the switch is on
Off Label* The label/icon when the switch is off
* You can use icons for the labels. There are a variety of icons offered at Font Awesome, allowing you to give visual indication to a user of what the switch control does.
Example
These are the configuration option settings...
This is the result...
Events
With the Switch control, there are 2 types of event handlers:
- On Load When the page loads
- On Change When there is a change
You can use JavaScript logic to affect the effects of the control, depending on the event. More information on using these controls can be found in the Event Handling article.
Methods
For detailed information on the available methods for this control, access the JS Doc file.
- Authors: Lisa Leung, Matthew Oatts
- Date Created: June 3, 2015
- Date Modified: September 11, 2015
Comments