Giter Club home page Giter Club logo

ampersand-radio-view's Introduction

ampersand-radio-view Build Status

An extension of ampersand-input-view to create radio buttons.

Adds a "text" property for , and "checked" to indicate if the button should be checked at render time.

install

npm install ampersand-radio-view

example

var FormView = require('ampersand-form-view');
var RadioView = require('ampersand-radio-view');

module.exports = FormView.extend({
    fields: function () {
        return [
            new RadioView({
                label: 'Gender',
                name: 'gender',
                value: 'female',
                required: false,
                text: 'Female',
                checked: this.model.gender ? (this.model.gender == 'female') : false,
                parent: this
            }),
            new RadioView({
                name: 'gender',
                value: 'male',
                required: false,
                text: 'Male',
                checked: this.model.gender ? (this.model.gender == 'male') : false,
                parent: this
            })
        ];
    }
});

opts

  • text (required): the text to be shown to the right of the button.
  • checked (default: false): indicates if the button should be checked at render time.

Note: the standard "type" property from ampersand-input-view is hardcoded in the radio control to "hidden", so there's really no benefit to putting type: "radio" in your declaration options. Suggestion: Only use the "label" property for the first radio view in the set, and use that label as the set's label.

changelog

credits

Thanks to the Ampersand group!

license

MIT

ampersand-radio-view's People

Contributors

engenb avatar mikehedman avatar

Watchers

 avatar  avatar

Forkers

stefanisak

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.