dojo的TabContainer中增加的ContentPane如果是closable,如何在关闭后不销毁ContentPane

来源:互联网 发布:网络数字电视无信号 编辑:程序博客网 时间:2024/06/05 20:12

主要思路是新建TabContainer的扩展类,重载其closeChild属性,使得其在关闭子容器时,不调用该子容器的destroyRecursive方法。

define([ "dojo/_base/declare", "dijit/layout/TabContainer" 

], function(declare,TabContainer) { 
        return declare("comm.comm.ExTabContainer", TabContainer, { 
                closeChildAction:"destroy", 
                closeChild: function(/*dijit/_WidgetBase*/ page){ 
                        // summary: 
                        // Callback when user clicks the [X] to remove a page. 
                        // If onClose() returns true then remove and destroy the child. 
                        // tags: 
                        // private 
                        var remove = page.onClose && page.onClose(this, page); 
                        if(remove){ 
                                this.removeChild(page); 
                                if (this.closeChildAction=="destroy"){ 
                                        // makes sure we can clean up executeScripts in ContentPane onUnLoad 
                                        page.destroyRecursive(); 
                                } 
                        } 
                } 
    }); 

 }); 

然后创建TabContainer的方法如下
var tc=new ExTabContainer({ 
  style : "height: 100%; width: 100%;", 
  isLayoutContainer : true, 
  region : 'center', 
  closeChildAction:"hide" 
}); 
0 0
原创粉丝点击