我有一个内容窗格(B),当我单击选项卡容器中另一个内容窗格(A)内的按钮时,会创建该窗格。在B中,我使用了closeable设置为true,并使用了on close函数。现在,当我关闭B时,它工作正常,但我的要求是,如果我单击A中的按钮,应再次创建B。我尝试在on close函数中为内容窗格变量分配null,以便再次创建新的内容窗格,但给出错误,无法读取null所有者文档的属性
dgsult0t1#
我认为你的问题出在showLayerListFunction内部,请参见下面的示例,其中您可以在删除选项卡后重新创建选项卡
showLayerListFunction
require(["dojo/on", "dojo/dom", "dojo/ready", "dijit/registry","dojo/dom-construct", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dijit/form/Button", "dojo/dom-style" ], function(On, dom, ready, registry,domConstruct, TabContainer, ContentPane, Button, domStyle) { ready(function() { var tabContainer = registry.byId("center"); var tab1 = registry.byId("tab1"); var btn = registry.byId("show"); btn.on("click", function(e){ // if pane exist skip creation if(!registry.byId("legendid")) { var tab2 = new ContentPane({title:"List",id:"legendid",closable:true }); tabContainer.addChild(tab2); tabContainer.selectChild(tab2) } }) }); });
html, body { width: 100%; height: 100%; margin: 0; } #center { height: 100% !important; }
<link href="//ajax.googleapis.com/ajax/libs/dojo/1.10.0/dijit/themes/claro/claro.css" rel="stylesheet" /> <script> dojoConfig = { parseOnLoad: true, async: true }; </script> <script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.0/dojo/dojo.js"></script> <body class="claro"> <div id="center" data-dojo-type="dijit/layout/TabContainer" > <div id="tab1" data-dojo-type="dijit/layout/ContentPane" title="tab1"> <div data-dojo-type="dijit/form/Button" id="show"> Show Layer List</div> </div> </div> </body>
1条答案
按热度按时间dgsult0t1#
我认为你的问题出在
showLayerListFunction
内部,请参见下面的示例,其中您可以在删除选项卡后重新创建选项卡