{{input type="radio" name="customerFacing" value=report.customerFacing id="customerFacingYes" change=(action "customerFacingChange" "yes")}}<label for="customerFacingYes">Yes</label>
我试图将单选按钮设置为选中状态,如果变量“ report.customerFacing”为true或false。有什么我可以用JavaScript编写并将其设置为选中状态的东西吗?
谢谢
您的代码将适用于该复选框。
{{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.
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句