
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
ampersand-checkbox-view
Advanced tools
A view module for intelligently rendering and validating checkbox input. Works well with ampersand-form-view.
Lead Maintainer: Michael Garvin
A view module for intelligently rendering and validating checkbox input. Works well with ampersand-form-view.
ampersand-checkbox-view extends ampersand-view, so you may further .extend({...})
it to your desire.
It does the following:
required
.Part of the Ampersand.js toolkit for building clientside applications.
npm install ampersand-checkbox-view
var CheckboxView = require('ampersand-checkbox-view');
var field = new CheckboxView({
// form input `name`
name: 'client_name',
// You can replace the built-in template with your own.
// just give it an html string. Make sure it has a single "root" element that contains:
// - an `<input>` element
// - an element with a `data-hook="label"` attribute
// - an element with a `data-hook="message-container"` attribute (this we'll show/hide)
// - an elememt with a `data-hook="message-text"` attribute (where message text goes for error)
template: // some HTML string
// Label name
label: 'App Name',
// optinal intial value if it has one
value: true, // or false
// optional, this is the element that will be
// replaced by this view. If you don't
// give it one, it will create one.
el: document.getElementByID('field'),
// whether or not this field is required
required: true, // false by default
// whether or not to disable this field
disabled: false, //false by default
// class to set on input when input is valid
validClass: 'input-valid', // <- that's the default
// class to set on input when input is valid
invalidClass: 'input-invalid', // <- that's the default
// Message to use if error is that it's required
// but no value was set.
requiredMessage: 'This box must be checked.',
// optional, you can pass in the parent view explicitly
parent: someViewInstance,
// optional, called before form's submitCallback function called
beforeSubmit: function() { console.log('ampersand-checkbox-view rocks!'); }
});
// append it somewhere or use it in side an ampersand-form-view
document.querySelector('form').appendChild(field.el);
Commonly accessed properties listed below. See the initialize()
function for additional properties available.
valid
(boolean)value
(boolean)startingValue
(boolean) - this is coerced from any initail value
provided during constructionnew CheckboxView()
- constructor
clear()
view.setValue(false);
reset()
view.setValue(this.startingValue);
setValue([boolean])
boolean
.domify
and using ampersand-view renderWithTemplate
autoRender
, clear
, reset
Created by @HenrikJoreteg.
MIT
FAQs
A view module for intelligently rendering and validating checkbox input. Works well with ampersand-form-view.
The npm package ampersand-checkbox-view receives a total of 36 weekly downloads. As such, ampersand-checkbox-view popularity was classified as not popular.
We found that ampersand-checkbox-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.