2
{{input type="radio" name="customerFacing" value=report.customerFacing id="customerFacingYes" change=(action "customerFacingChange" "yes")}}<label for="customerFacingYes">Yes</label>

I am trying to set the radio button as selected if a variable, "report.customerFacing", is true or false. Is there something I could write in javascript to set it as selected?

Thank you

LizEveno
  • 23
  • 1
  • 4
  • You have to create a custom component, Please check here http://stackoverflow.com/questions/30244040/recording-values-of-radio-buttons-in-ember – prudvi raju Jul 29 '16 at 16:50

1 Answers1

0

Your code will work for the checkbox.

{{input type="checkbox" name="customerFacing"  checked=report.customerFacing value=report.customerFacing id="customerFacingYes" on-change=(action (mut report.customerFacingChange) checked)}} 
<label for="customerFacingYes">{{report.customerFacing}}</label>

But for the radio button you can try addon.(https://github.com/yapplabs/ember-radio-button)

ember install ember-radio-button

{{#radio-button value=report.customerFacing groupValue=report.customerFacing class="cpntr" changed=(action "customerFacingChange")}}
      <label for="customerFacingYes">{{report.customerFacing}}</label>
 {{/radio-button}}

In controller or in any other place,

actions: {
 customerFacingChange(newValue){
  console.log('Changed value'+newValue); //you can do other stuff here.
 }
}
nem035
  • 34,790
  • 6
  • 87
  • 99
Ember Freak
  • 12,918
  • 4
  • 24
  • 54