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

変数 "report.customerFacing"がtrueまたはfalseの場合、ラジオボタンを選択して設定しようとしています。私は選択としてそれを設定するためにJavaScriptで書くことができるものはありますか?Emberでどのようにデフォルトのラジオボタンを選択しますか?

ありがとうございました

+0

あなたは、カスタムコンポーネントを作成してください必要がありここをクリックhttp://stackoverflow.com/questions/30244040/recording-values-of-radio-buttons-in-ember –

答えて

0

あなたのコードはチェックボックスで機能します。

{{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> 

しかし、あなたはアドオンを試すことができますラジオボタンの

。( 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}} 

コントローラまたは任意の他の場所で、

actions: { 
customerFacingChange(newValue){ 
    console.log('Changed value'+newValue); //you can do other stuff here. 
} 
} 
関連する問題