如何在Ember中选择默认单选按钮
How do you select a default radio button in Ember?
{{input type="radio" name="customerFacing" value=report.customerFacing id="customerFacingYes" change=(action "customerFacingChange" "yes")}}<label for="customerFacingYes">Yes</label>
如果变量"report.customerFaceing"为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>
但对于单选按钮,你可以试试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}}
在控制器或任何其他地方,
actions: {
customerFacingChange(newValue){
console.log('Changed value'+newValue); //you can do other stuff here.
}
}
相关文章:
- 或者在表单上选择默认选项文本(选择1)
- Selectize选择默认值
- 如何将鼠标选择默认效果转换为在网站中滚动/滑动
- 在多选下拉列表中选择默认值
- 在 Angular JS 中为 ng 选项选择默认值
- 如何从 AngularJS 的下拉框中设置选择默认值
- 当 ng-model 和 ng-options 引用不同的对象时,如何使用 ng-init 在选择框中选择默认值
- 设置 Ember.选择“默认选定值”
- 为“角度”中的下拉列表选择默认值
- 在 html 下拉列表中选择默认值
- 选择默认类为'活动'打开iframe
- 在angularjs中选择,而不是选择默认值
- 从下拉列表中删除所选选项将选择默认选项,而不是下一个所选选项
- AngularJS选择下拉菜单-选择默认选项
- JSP下拉列表选择默认情况下使用struts加载页面的第一个选项
- 选择默认箭头不'不要躲在FF上
- easyUI数据网格内部编辑组合框无法选择默认值
- 角度设置ui从另一个控制器中选择默认值
- HTML JS选择默认选项
- AngularJS ngOptions选择默认选项