Force Check Controller

Force Check Controller is a Stimulus controller for forcing a checkbox to stay checked.

Attributes

HTML Attributes

These are standard HTML attributes (with no prefix) used by the controller.

data- Attributes

All of these attributes are prefixed with "data-" in the attribute name.

Attribute Element(s) Default Value(s) Description
controller (any)
forcecheck This attribute provides the controller functionality.

data-forcecheck- Attributes

All of these attributes are prefixed with "data-forcecheck-" in the attribute name.

Attribute Element(s) Default Value(s) Description
alert (controller)
input[type="checkbox"]
If this attribute is provided then the controller will alert the user when the checkbox is forced to stay checked or unchecked.
The text of the alert will be the value of this attribute for the checkbox or (if not on the checkbox) the controller.
If no value is provided for the any alert attribute then the controller will not alert the user.
Note: This attribute is not required for the controller to work.
force input[type="checkbox"]
If the attribute is not provided or is not true or false then Force Check will take no action.
true Force Check will force the checkbox to be checked.
false Force Check will force the checkbox to be unchecked.

Events

forcecheck: Events

These are custom events that the controller will fire when it takes certain actions.

All of these events are prefixed by "forcecheck:".

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.
forced

target: (the target element)
forceValue: (the value that was forced)

Called any time that the controller forces a checkbox to be checked or unchecked.