我在 ember 中使用复选框时遇到问题。我使用了一个 bool 属性来检查绑定(bind)。现在我想在更改此属性或单击复选框时触发事件,但是当我单击它时它不会触发任何事件。即使它不会在更改该属性时调用观察者函数。下面是我的代码片段,
在“setAsRecurringAction”上的 View-observer 中选中的属性或者这可以是点击事件处理程序。
setActionSchedule: function() {
if (this.get('setAsRecurringAction')) {
$(".response-container").css({height: '38em'});
} else {
$(".response-container").css({height: '19em'});
}
}.observes('setAsRecurringAction')
模板-
{{view Ember.Checkbox
checkedBinding="setAsRecurringAction"
class="set-recurring"}}
同样的代码和 action helper 也不起作用,
{{view Ember.Checkbox
checkedBinding="setAsRecurringAction"
class="set-recurring"
action="setActionSchedule"}}
- 更多信息,当我选中复选框时会抛出错误,例如“未捕获的类型错误:无法调用未定义的方法‘查找’”
提前谢谢
最佳答案
查看 jsfiddle
我刚刚创建。
如果 setActionSchedule 是在 View 中定义的,那么您必须更改您的checkedBinding 路径。
{{view Ember.Checkbox
checkedBinding="view.setAsRecurringAction" }}
关于javascript - Ember 复选框单击,更改事件未触发,给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15086478/