简体   繁体   English

将复选框添加到复选框组->侦听器

[英]Adding checkboxes to checkbox group -> listener

I have a checkbox group to which I now add checkboxes at runtime. 我有一个复选框组,现在可以在运行时向其中添加复选框。 The problem is my change listener, which is defined on the checkboxgroup. 问题是我的更改侦听器,该侦听器在复选框组上定义。 It is not fired when the new checkboxes are checked - but it is when the old ones are. 选中新复选框时不会触发它,而旧复选框则被触发。 (Furthermore, it is not fired when new checkboxes are added - although the new checkboxes are created checked:true ) (此外,添加新的复选框时不会触发它-尽管创建的新复选框为checked:true

So I want to add the change listener, which is defined on the checkboxgroup in variable me , to all child checkboxes. 因此,我想将更改侦听器(在变量me的复选框组中定义)添加到所有子复选框。 I think this has to be the way Ext does it, right? 我认为这一定是Ext的方式,对吗?

newItems.push(Ext.create('Ext.form.field.Checkbox',Ext.applyIf(Ext.clone(me.defaults),{
    boxLabel : someString,
    name : someString,
    inputValue : someString,
    checked : true,
    listeners : {
        change: me.on('change');
    }
})));

But I am unsure how to achieve my goal (in the third-to-last-line), that the change event for the checkboxgroup is fired whenever the change event is fired for the checkbox. 但是我不确定如何实现我的目标(在倒数第三行中),只要为复选框触发更改事件就触发复选框组的更改事件。

I found the answer: 我找到了答案:

change:function() { me.fireEvent('change'); }

would fire the change event on the checkbox group whenever the change event on the checkbox is triggered. 每当触发复选框上的更改事件时,都会在复选框组上触发更改事件。

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

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