DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
      • Pages
        • select[multiple]
        • input[type=checkbox]
        • input[type=radio]
        • select
      • Converters
        • boolean-to-inList
        • either-or
        • equal
        • index-to-selected
        • not
        • string-to-any
    • can-stream
    • can-vdom
    • can-view-import
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-stache-converters
  • /
  • input[type=radio]
  • / On this page
    • input[type=radio]

      page

      Cross bind a value to a radio input.

      • source

      Binding to radios

      To bind to a radio input, if you have a set of boolean values you can bind to the input's checked property as you do with input[type=checkbox].

      <input type="radio" {($checked)}="one" /> One
      <input type="radio" {($checked)}="two" /> Two
      
      var template = stache.from("demo");
      var map = new DefineMap({
          one: true,
          two: false
      });
      
      document.body.appendChild(template(map));
      

      Binding to a selected value

      More often than binding to boolean values of each radio's checked value, you will want to know what the value is of the radio group. Since each radio has it's own value, the radio's selected value is the value of the radio item that is selected.

      Using the converter equal you can bind a value within your scope to the radio group's selected value:

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.