The checkbox control provides a customized look and feel that can be standardized across all browsers.
Initialize the checkbox control via JavaScript:
{% highlight js %}$('#myCheckbox').checkbox();{% endhighlight %}$.ready() executes that have data-initialize="checkbox" on their parent will be initialized immediately.data-initialize="checkbox" after $.ready() executes will initialize when a mouseover event occurs on them.Before v3.8.0, the checkbox control could be bound with $().checkbox(); or data-initialize="checkbox" to the div.checkbox or the input elements. This is no longer supported. Please update your markup and JavaScript to be bound to the label only.
Once your checkbox is initialized, you can execute any of the following methods on it:
true or false indicating the checked state of the checkbox.| Event Type | Description |
|---|---|
| enabled.fu.checkbox | Event fires when checkbox is enabled |
| disabled.fu.checkbox | Event fires when checkbox is disabled |
| checked.fu.checkbox | Event fires when checkbox is checked |
| unchecked.fu.checkbox | Event fires when checkbox is unchecked |
All checkbox events are fired on the .checkbox classed element. However, unlike the majority of Fuel UX controls, it is recommended to listen to and check the state of the checkbox control by listening to the native checkbox with the change event and check its status with the presence of the checked attribute. For the sample markup provided, this would be:
Use the .checkbox-inline class on checkboxes for controls that appear on the same line.
Place any checkbox option within an input group's addon instead of text.
Use the data-toggle="{{selector}}" to automatically show or hide elements matching the selector within the body upon check or uncheck. This control works with any jQuery selector.
Use the .highlight class to add a background highlight upon check.
Unlike the majority of Fuel UX controls, it is recommended to listen to and check the state of the checkbox control by listening to the native checkbox with the change event and check its status with the presence of the checked attribute. For the sample markup provided, this would be: