A set of UI checkboxes that interact as one group.
Example
<!--The following HTML includes a checkbox collection component containing a single checkbox.
An element is specified as a checkbox collection by setting the data-pcc-component attribute
to "checkboxcollection".-->
<span data-pcc-component="checkboxcollection"
data-pcc-name="required"
data-pcc-value="required"
data-pcc-label="Required"
class="pcc-margin"></span>
Example
// Require the checkbox collection module.
var CheckboxCollection = require('../elements/checkbox-collection.js');
// Pass each checkbox collection element to the checkbox collection module to initialize each checkbox.
// parent is the element that contains the checkbox collection element.
$(parent).find('[data-pcc-component="checkboxcollection"]').each(function() {
CheckboxCollection(this);
});
(require("checkbox-collection"))(el) → {HTMLElement}
Parses and initializes a checkbox collection.
Parameters:
Name | Type | Description |
---|---|---|
el |
HTMLElement |
The parent element in which to parse for the checkbox collection component. |
Returns:
The parsed checkbox collection element.
- Type
- HTMLElement
Members
(static) pccElements :Object
The checkbox elements in the checkbox collection.
Type:
- Object
off :module:event-store~off
Removes an event handler from the checkbox collection.
Type:
- module:event-store~off
on :module:event-store~on
Registers an event handler on the checkbox collection.
Type:
- module:event-store~on
Methods
destroy()
Destroys the checkbox collection component.
value(val) → {Object}
Gets or sets the values of the checkbox collection. The values are specified in the HTML for each checkbox using the data-pcc-value attribute.
Parameters:
Name | Type | Description |
---|---|---|
val |
Array |
An array of values to check the corresponding checkbox elements. |
Returns:
The checkbox collection element if a value is passed. Otherwise, an array of the values that correspond to the currently checked checkboxes is returned.
- Type
- Object