2011-02-18 74 views
0

我希望能够在用户点击关闭按钮时销毁YUI面板。如何在关闭时销毁YUI面板?

我尝试过使用hideEvent但那不起作用。我假设,因为对象是仍处于活动状态,因此不能被破坏:

panel.hideEvent.subscribe(function(o) { 
    panel.destroy(); 
}); 

有没有一种方法,当用户点击关闭我可以摧毁面板?虽然它被赋予一个类的关闭按钮未分配的ID:

<a class="container-close" href="#">Close</a> 

回答

3

结束了其使用的setTimeout()函数:

panel.hideEvent.subscribe(function(o) { 
    setTimeout(function() {panel.destroy();}, 0); 
}); 
0

如果赢是YUI简单的对话,我用这个:

w.win.hideEvent.subscribe(function(e) { 
                this.destroy(); 

}); 
0

使用上面的hideEvent导致firebug中的javascript错误。以下解决方案没有问题:

dlg - > yui2对话框的实例或类似的。 dlg.close - >是关闭图标

具有呈现的对话框后使用下面的代码的html元素:

//remove the default click handler (._doClose) 
YAHOO.util.Event.removeListener(dlg.close, "click"); 

//add a new click handler (._doClose) 
YAHOO.util.Event.on(dlg.close, "click", function(){ 
    this.destroy(); 
}, dlg, true);