-
FEATURED COMPONENTS
First time here? Check out the FAQ!
hello every one i'm trying to show/hide a popup window using a view model, but it's not working.
in my view model i have a property called visible and a method where i set visible to true to show the popup window:
//command to show popup @Command("details") @NotifyChange("visibleDetails") public void showDetails(){ this.visibleDetails=true; } //command to hide popup @Command @NotifyChange("visibleDetails") public void hide(){ this.visibleDetails=false; }
this is the command in the zul:
<image src="/images/detail14.png" onClick="@command('details')" ></image>
and here's my popup window in the same zul:
<window id="w_details" mode="popup" closable="true" position="center" width="60%" visible="@load(vm.visibleDetails)" onClose="@command('hide')"></window >
It seems impossible to do it according to this but anyway i'm posting the "same zul".
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.testVM')"> <image src="/images/detail14.png" onClick="onClick="@command('details')" ></image> <window xmlns:a="http://www.zkoss.org/2005/zk/annotation" mode="popup" closable="true" position="center" width="60%" visible="@load(vm.visibleDetails)" onClose="@command('hide')"> </window> </window>
I can do it. Check this (using zk 6.0.2):
zul
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('TestVM')"> <image src="/demo.jpg" onClick="@command('details')" /> <window mode="popup" position="center" width="200px" visible="@load(vm.visibleDetails)" border="normal" title="Title"> <label value="Hello!" /> <button label="Close" onClick="@command('hide')" /> </window> </window>
TestVM.java
import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.NotifyChange; public class TestVM { private boolean visibleDetails; public boolean getVisibleDetails() { return visibleDetails; } @Command("details") @NotifyChange("visibleDetails") public void showDetails() { this.visibleDetails = true; } @Command @NotifyChange("visibleDetails") public void hide() { this.visibleDetails = false; } }
@paowang: thank you.I know it works that way . But i was trying to use the default close button. As you can see i set the closable attribute to true.
Thank you anyway.
Hi you can see this also..
<button label="Cancel" onClick="modelWindowId.detach()" />
Where modelWindowId. is the id of your model window..
In Your case it will be something like this.
<button label="Cancel" onClick="w_detailsd.detach()" />
Thanks
Asked: 2012-06-27 13:11:43 +0800
Seen: 218 times
Last updated: Sep 14 '12