简体   繁体   English

灰烬复选框单击,更改事件未触发,给出错误

[英]Ember checkbox click, change event not firing, gives error

I have problem during use of checkbox in ember. 我在使用余烬中的复选框时遇到问题。 I have used one boolean property for checked binding. 我使用了一个布尔属性来进行检查绑定。 Now i want to fire a event on change of this property or click on checkbox, but when i clicks it doesn't fires any of the event. 现在,我想在更改此属性时触发事件,或者单击复选框,但是当我单击它时,不会触发任何事件。 Even it doesn't calls observer function on change of that property. 即使它不更改该属性也调用观察者函数。 below is the my code snippet, 以下是我的代码段,

in View- observer on "setAsRecurringAction" checked property or this can be a click event handler. 在View-observer中的“ setAsRecurringAction”选中属性上,否则可以是单击事件处理程序。

setActionSchedule: function() {
    if (this.get('setAsRecurringAction')) {
        $(".response-container").css({height: '38em'});
    } else {
        $(".response-container").css({height: '19em'});
    }
}.observes('setAsRecurringAction')

template- 模板-

{{view Ember.Checkbox 
     checkedBinding="setAsRecurringAction"
     class="set-recurring"}}

and same code with action helper also didn't work, 并且带有动作帮助器的相同代码也无法正常工作,

{{view Ember.Checkbox 
    checkedBinding="setAsRecurringAction"
    class="set-recurring"
    action="setActionSchedule"}}
  • Some more info when i checks the checkbox throws error like "Uncaught TypeError: Cannot call method 'find' of undefined" 当我检查复选框时会抛出更多信息,例如“未捕获的TypeError:无法调用未定义的方法'find'”

thnx in advance. 提前thnx。

Take a look to the jsfiddle i just created. 看一下我刚刚创建的jsfiddle

If setActionSchedule is defined in a view then your have to change your checkedBinding path . 如果在视图中定义了setActionSchedule ,那么您必须更改checkedBinding路径

{{view Ember.Checkbox 
    checkedBinding="view.setAsRecurringAction" }}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM