Types
Checkbox
A standard checkbox
Slider
A checkbox can be formatted to emphasize the current selection state
Toggle
A checkbox can be formatted to show an on or off choice
Radio Box
A checkbox can be formatted as a radio element. This means it is an exclusive option.
States
Read-only
A checkbox can be read-only and unable to change states
Disabled
A checkbox can be read-only and unable to change states
Checkbox
A checkbox can be initialized with javascript for increase programmatic control
Basic Checkbox
A checkbox can also be used without using javascript by matching the id
attribute of the input field to the for
attribute of the accompanying label
Behavior
enable | A checkbox can change to show a user has selected it |
disable | A checkbox can change to show a user has deselected it |
toggle | A checkbox can toggle its current selection state |
Examples
Disabled / Read Only / Forced
To disable a checkbox, add the property disabled
to your input.
To make a checkbox read-only do not initialize it, or include the read-only
class which will not allow events even if initialized.
To make a user able to check a box, but unable to uncheck it, use the uncheckable
setting.
Attaching Events to other Elements
Checkbox can use the attach events
behavior to attach events easily to other activating elements. This defaults to toggling, but other behaviors can be used as well.
Checkbox Settings
Checkbox settings modify its behavior
Setting | Default | Description |
---|---|---|
required | auto | Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes |
context | false | A selector or jQuery object to use as a delegated event context |
Callbacks
Callbacks specify a function to occur after a specific behavior.
Setting | Context | Description |
---|---|---|
onChange | Checkbox | Callback after a checkbox is either disabled or enabled. |
onEnable | Checkbox | Callback after a checkbox is enabled. |
onDisable | Checkbox | Callback after a checkbox is disabled. |
DOM Settings
DOM settings specify how this module should interface with the DOM
Setting | Default | Description |
---|---|---|
namespace | checkbox | Event namespace. Makes sure module teardown does not effect other events attached to an element. |
selector |
selector : {
input : 'input',
label : 'label'
}
|
|
className |
className : {
radio : 'radio'
}
|