-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm using this pattern to implement complex dynamic tooltips.
My problem is that my "tooltip calculation code" can return "no tooltip". How do I prevent the popup from showing in this case?
I tried to call popup.close()
in the ON_OPEN
event listener but that causes the popup to flicker.
why can't you just decide to show or not before calling show()?
if you can't, you can post a event after call popup.open()
. and the listener (I guess it is the popup itself) can listen to the event to call close.
<zk>
<zscript>
void show(Component comp,String text){
helptext.setContent(text);
help.open(comp);
Events.postEvent(help,new Event("onShowCheck"));
}
void onShowCheck(){
if(org.zkoss.lang.Strings.isEmpty(helptext.getContent())){
help.close();
}
}
</zscript>
<hbox>
<button label="show1" onClick='show(self,"Show me")'/>
<button label="show2" onClick='show(self,null)'/>
</hbox>
<popup id="help" onShowCheck="onShowCheck()">
<html id="helptext"/>
</popup>
</zk>
Read the last part of RobertPic's writing how he does handle the popup. Seems meantime he create a MyPopup class that extends from GenericForwardComposer. In this case you can check if data exists in the doAfterCompose() method. If there is no data to shown you can call a myPopup.detach(). So it sould not flicker.
best Stephan
Asked: 2013-02-25 15:57:09 +0800
Seen: 41 times
Last updated: Feb 26 '13