Ember 退出视图后永远不会清除单选按钮
Ember radio button never be cleared after exiting the view
我有一个带有 5 个单选按钮的把手:
<ui>
<li> <label>
{{view Ember.RadioButton id="option1" name="selectionTest" selectionBinding="isSelected" value=1}}
<b>{{i18n 'kwoption1'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option2" name="selectionTest" selectionBinding="controllerisSelected" value=2 valueBinding="radio1"}}
<b>{{i18n 'kwoption2'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option3" name="selectionTest" selectionBinding="isSelected" value=3}}
<b>{{i18n 'kwoption3'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option4" name="selectionTest" selectionBinding="isSelected" value=4}}
<b>{{i18n 'kwoption4'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option5" name="selectionTest" selectionBinding="isSelected" value=5}}
<b>{{i18n 'kwoption5'}}</b>
</label></li>
</ui>
当我点击 提交 按钮时,它会清除所有单选按钮,但在退出屏幕并尝试再次访问它后,我得到的是旧的选定值。
如何清除此车把上的缓存?
在您的提交操作中,在不再需要这些值之后但在转换路由之前调用一个清除所有选择的方法。
最后,我通过将选择值设置为“”向 Ember.RadioButton 添加初始化函数来解决问题,如下所示:
Ember.RadioButton = Ember.View.extend({
tagName : "input",
type : "radio",
attributeBindings : [ "name", "type", "value", "checked:checked:" ],
click : function() {
cValue=(this.set("selection", this.$().val()).value).toString();
this.set("selection", this.$().val());
},
init: function() {
cValue=null;
this.set("selection", "");
},
checked : function() {
return this.get("value") == this.get("selection");
}.property()
});
感谢大家的陪伴
我有一个带有 5 个单选按钮的把手:
<ui>
<li> <label>
{{view Ember.RadioButton id="option1" name="selectionTest" selectionBinding="isSelected" value=1}}
<b>{{i18n 'kwoption1'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option2" name="selectionTest" selectionBinding="controllerisSelected" value=2 valueBinding="radio1"}}
<b>{{i18n 'kwoption2'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option3" name="selectionTest" selectionBinding="isSelected" value=3}}
<b>{{i18n 'kwoption3'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option4" name="selectionTest" selectionBinding="isSelected" value=4}}
<b>{{i18n 'kwoption4'}}</b>
</label></li>
<li> <label>
{{view Ember.RadioButton id="option5" name="selectionTest" selectionBinding="isSelected" value=5}}
<b>{{i18n 'kwoption5'}}</b>
</label></li>
</ui>
当我点击 提交 按钮时,它会清除所有单选按钮,但在退出屏幕并尝试再次访问它后,我得到的是旧的选定值。
如何清除此车把上的缓存?
在您的提交操作中,在不再需要这些值之后但在转换路由之前调用一个清除所有选择的方法。
最后,我通过将选择值设置为“”向 Ember.RadioButton 添加初始化函数来解决问题,如下所示:
Ember.RadioButton = Ember.View.extend({
tagName : "input",
type : "radio",
attributeBindings : [ "name", "type", "value", "checked:checked:" ],
click : function() {
cValue=(this.set("selection", this.$().val()).value).toString();
this.set("selection", this.$().val());
},
init: function() {
cValue=null;
this.set("selection", "");
},
checked : function() {
return this.get("value") == this.get("selection");
}.property()
});
感谢大家的陪伴