Coder Social home page Coder Social logo

fbaiodias / ampersand-array-checkbox-view Goto Github PK

View Code? Open in Web Editor NEW
4.0 6.0 1.0 181 KB

:ballot_box_with_check: A view module for rendering and validating multiple checkbox inputs.

Home Page: https://www.npmjs.com/package/ampersand-array-checkbox-view

JavaScript 100.00%

ampersand-array-checkbox-view's Introduction

ampersand-array-checkbox-view

A view module for rendering and validating multiple checkbox inputs. Works well with ampersand-form-view.

It does the following:

  • Automatically shows/hides error message based required.
  • Will only show error message if the number of selected checkbox if off the specified limits

install

npm install ampersand-array-checkbox-view

try it out

npm run demo

example

var FormView = require('ampersand-form-view');
var CheckboxArray = require('ampersand-array-checkbox-view');

module.exports = FormView.extend({
  fields: function () {
      return [
        new CheckboxArray({
          // form input `name`
          name: 'color',
          // You can replace the built-in templates with your own.
          template: // some HTML string
          fieldTemplate: // some HTML string
          // Label name
          label: 'Pick a color!',
          // you can pass simple string options
          options: ['blue', 'orange', 'red'],
        }),
        new CheckboxArray({
          name: 'option',
          // you can also pass pairs, first is the value, second is used for the label
          options: [ ['a', 'Option A'], ['b', 'Option B'], ['c', 'Option C'] ]
        })
      ];
    }
});

credits

Created by Francisco Dias.

license

MIT

ampersand-array-checkbox-view's People

Contributors

alluriprasad avatar fbaiodias avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

alluriprasad

ampersand-array-checkbox-view's Issues

Validation error message not showing

I am using an ampersand-array-checkbox-view within an ampersand-form-view as shown here: http://requirebin.com/?gist=436ad1b0dcc20020e741.

Unfortunately, when no option is select, ne error message is displayed to the user upon pressing submit, even though the form is correctly identified as not being valid and the submit is prevented.

I found a similar issue with the ampersand-select-view, as reported here: AmpersandJS/ampersand-select-view#47

Maybe the cause of the error is similar?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.