| Authors: | Doug Hays |
|---|---|
| Developers: | ?- |
| since: | V? |
Contents
| full API: | http://dojotoolkit.org/api/dijit/form/ToggleButton |
|---|
Signature
var thing = new dijit.form.ToggleButton( /* Object */ params, /* DomNode|String */ srcNodeRef)
ToggleButton widgets are a cross between Button and Checkbox widgets. They are created like Button widgets, but like CheckBox widgets, they maintain a checked boolean attribute (settable/gettable) that toggles on each click action. Unlike CheckBox widgets however, ToggleButton widgets do not submit any value on FORM submit. They are used solely for client-side processing where the user can toggle between 2 states before performing some additional action. The CSS class "dijitToggleButtonChecked" is appended to the widget's outermost DOM node when the checked attribute is true to allow for custom styling.
Let's create a ToggleButton widget programmatically, initially unchecked:
require(["dojo/ready", "dijit/form/ToggleButton"], function(ready, ToggleButton){
ready(function(){
new ToggleButton({
showLabel: true,
checked: false,
onChange: function(val){this.set('label',val)},
label: "false"
}, "programmatic");
});
});
<button id="programmatic"></button>
Now let's create a ToggleButton widget with HTML markup, initially checked:
require(["dojo/parser", "dijit/form/ToggleButton"]);
<button data-dojo-type="dijit/form/ToggleButton" data-dojo-props="iconClass:'dijitCheckBoxIcon', checked: true">
Toggle me
</button>
| Action | Key |
| Navigate to a ToggleButton | Tab |
| Toggle checked state | Spacebar |