如何将 Checkbox 的 onCheck 事件传递给 zk 中的父级? [英] How can I pass on the onCheck event of a Checkbox to its parent in zk?
本文介绍了如何将 Checkbox 的 onCheck 事件传递给 zk 中的父级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有一些复选框的 vbox,如下所示:
I have a vbox with some checkboxes in it, like so:
<vbox id="myVbox" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('my.checkbox.group.CheckboxGroupViewModel', outerVM=wvm, component=self)">
<checkbox id="1"/>
<checkbox id="2"/>
<checkbox id="3"/>
</vbox>
有没有办法让 vbox 对其任何孩子的 onCheck 事件做出反应?
Is there a way to make the vbox react to any of its children's onCheck event?
vbox 是窗口的一部分,该窗口具有其视图模型.其中,有以下代码动态添加收音机:
The vbox is part of a window that has its on viewmodel. In it, there is the following code to add the radios dynamically:
if (childName.equals("org.zkoss.zul.Checkbox")) {
child.addEventListener("onClick", new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
Events.sendEvent(new Event("onSelectionChange",parent));
}
});
}
父变量代表vbox.vbox 的视图模型包含一个 onSelectionChange 方法.但它似乎永远不会被调用.
The parent variable represents the vbox. The viewmodel of the vbox contains an onSelectionChange method. But it seems to never get called.
推荐答案
你可以试试这个:
<vbox onSelectionChange="@command('METHODNAME_TO_IMPLEMENT_EVENT')"/>
这篇关于如何将 Checkbox 的 onCheck 事件传递给 zk 中的父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文