undefined

API Docs for: 5.4.0
Show:

Checkbox Class

Wraps the specified checkbox input nodes to provide an alternative rendering of checkbox without compromising its functionality. Handles synchronization of the checkbox's state with its new rendering. Also adds highlight/unhighlight on focus/unfocus, update label when checked/unchecked

Imports RAMP Modules:

Util

Constructor

Checkbox

(
  • node
  • [options]
)
Checkbox

Parameters:

  • node JObject

    a jQuery object representing the input checkbox node to be wrapped

  • [options] Object optional

    Additional options

    • [nodeIdAttr] String optional

      Name of the "data-" attribute set on the checkbox node to be treated as the checkbox id. If no appropriate "data-" attribute found, nodeIdAttr is used directly, failing that, regular id is used.

    • [cssClass] Object optional

      active, focus, and check CSS class to be applied to the Checkbox correspondingly.

      • [active] Object optional
        CSS class to be set when the Checkbox is active.
      • [focus] Object optional
        CSS class to be set when the Checkbox is focused.
      • [check] Object optional
        CSS class to be set when the Checkbox is checked.
    • [label] Object optional

      check and uncheck label texts to be applied to the Checkbox labels.

      • [check] Object optional
        A text to be set as a label when the Checkbox is checked
      • [uncheck] Object optional
        A text to be set as a label when the Checkbox is unchecked
    • [onChnage] Function optional

      A function to be called when the state of the Checkbox changes.

Returns:

Checkbox:

A control objects allowing to toggle checkbox.

Methods

_emit

(
  • agency
)
private

Emits a TOGGLE event when the checkbox's state is changed.

Parameters:

  • agency String

    Specified the agency that toggled the Checkbox.

setState

(
  • state
)
Checkbox chainable

Toggle the state of Checkbox.

Parameters:

  • state Boolean

    Specifies the state of the checkbox: true, false

Returns:

Checkbox:

Control object for chaining

validate

() Checkbox chainable

Validates that the checkbox node is in fact in dom. If not, set checkbox's state to "checkbox-invalid" to prevent any interactions.

Returns:

Checkbox:

Control object for chaining

Properties

agency

Object private

An object specifying possible agencies that can affect the Checkbox.

Example:

 agency: {
      USER: "USER",
      CODE: "CODE"
  }

cssClass

Object

active, focus, and check CSS class to be applied to the Checkbox correspondingly.

Example:

 cssClass: {
     active: "active",
     focus: "focused",
     check: "checked"
 }

event

Object private

Event names published by the Checkbox

Default: null

Example:

 {
     TOGGLE: "checkbox/toggle"
 }

id

String

Id of the Checkbox as specified by nodeIdAttr.

Default: null

label

Object

check and uncheck label texts to be applied to the Checkbox labels.

Example:

 label: {
     check: "check",
     uncheck: "unchecked"
 }

labelNode

JObject private

Node of the input checkbox label.

Default: null

node

JObject

Node of the input checkbox originally supplied to the Checkbox.

Default: null

nodeIdAttr

String

Name of the "data-*" attribute set on the checkbox node to be treated as the checkbox id.

Default: "id"

onChnage

Function

A function to be called when the state of the Checkbox changes.

Example:

 function () { }

state

Boolean | String

State of the Checkbox: true | false or INVALID

Default: null

Events

TOGGLE

Published whenever a Checkbox get toggled.

Event Payload:

  • event Object
    • checkbox Checkbox

      Checkbox object that has been toggled

    • agency String

      Agency that toggled the Checkbox