Radio Toggle Controller is a Stimulus controller to allow a user to toggle a radio button on or off, so that nothing is selected.
Indicated by data-{{name}}-target attribute.
| Target | Element(s) | Description |
|---|---|---|
| radio |
input[type="target"] |
This indicates a radio button that should be toggled on or off. The "data-action" attribute will be added to this element. |
These are standard HTML attributes (with no prefix) used by the controller.
All of these attributes are prefixed with "data-" in the attribute name.
| Attribute | Element(s) | Default | Value(s) | Description |
|---|---|---|---|---|
| controller |
(any) |
radiotoggle |
This attribute provides the controller functionality. |
|
| action |
(input[type="radio"]) |
click->radiotoggle#toggle |
This value will be used to trigger the controller when the radio button is clicked. It is automatically added to any radio button with a "data-radiotoggle-target" attribute of "radio". |
All of these attributes are prefixed with "data-radiotoggle-" in the attribute name.
| Attribute | Element(s) | Default | Value(s) | Description |
|---|---|---|---|---|
| target |
input[type="target"] |
radio |
This indicates a radio button that should be toggled on or off. The "data-action" attribute will be added to this element. |
These are custom events that the controller will fire when it takes certain actions.
All of these events are prefixed by "faker:".
| Event | Parameters | Description |
|---|---|---|
| initialized | Called any time that the controller is initialized. | |
| connected | Called any time that the controller is connected. | |
| disconnected | Called any time that the controller is disconnected. | |
| toggled |
target: (the element that is cleared) checked: (indicates if the radio button is checked or not) |
Called any time that the controller is disconnected. |
While it is recommended to use the controller via the attributes listed above, the following methods can be called directly if needed.
| Method | Returns | Arguments | Event(s) | Description |
|---|---|---|---|---|
| toggle | (event) |
Toggled the radio button on or off. Called when the radio button is clicked. |