删除并使用内容窗格创建dojo accordian容器

时间:2013-09-17 14:26:56

标签: dojo dijit.layout dojo-1.8

我是Dojo的新手,我正在使用Dojo 1.8,这是我想要做的 - 我创建了一个带有一些内容窗格的手风琴容器。这是有效的,当我点击页面上的一些按钮我调用一个函数(del),在这里我想删除现有的accordian容器及其内容窗格。然后使用一些不同的内容窗格重新创建手风琴容器。 调用del函数后,acordian容器不可见/创建,我没有看到任何错误

require(["dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dojo/domReady!"], function( AccordionContainer, ContentPane){
var myPane = new ContentPane({id: "mycnpane",title: "This is a content pane", content: "<div id='lastContentPaneId'>my content pane</div>", style:"height:100px", doLayout: true});
var aContainer = new AccordionContainer({id: 'myacc', style:"height: 100%"}, "markup");
aContainer.addChild(new ContentPane({
title: "This is a content pane",
content: "Hi", style:"height: 80px", doLayout: false
}));
aContainer.addChild(new ContentPane({
title:"This is as well",
content:"<li><a href='javascript:void(0)' >report</a></li>", doLayout: true
}));
aContainer.addChild(new ContentPane({
title:"This too",
content:"Hello im fine.. thnx"
}));
aContainer.addChild(myPane);
aContainer.startup();
});

function del(){
require(["dijit/registry", "dojo/dom","dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dojo/domReady!"], function( registry, dom, AccordionContainer, ContentPane){
var aContainer = registry.byId("myacc");

console.log(aContainer);

if(aContainer){

aContainer.destroyRendering(false);
aContainer.destroy(false);

}

aContainer = new AccordionContainer({style:"height: 100%","isLayoutContainer": true, "doLayout": false}, "markup");
console.log('testacc container::'+aContainer);

var mypane = new ContentPane({ id: '123', title: 'newly', doLayout: true });
mypane.set('content','<ul><li>1</li><li>2</li></ul>');

var mypane1 = new ContentPane({ id: '1234', title: 'newly', doLayout: true });
mypane1.set('content','<ul><li>1</li><li>2</li></ul>');

aContainer.addChild(mypane);
aContainer.addChild(mypane1);
aContainer.startup();

});
}

1 个答案:

答案 0 :(得分:0)

您可以简单地使用而不是

aContainer.destroyRendering(false);

aContainer.destroy(false);

使用

aContainer.destroyRecursive();

它适用于我使用的所有小部件。如果那不起作用尝试使用placeAt将手风琴放在标记div中,这将是这样的

var aContainer = new AccordionContainer({id: 'myacc', style:"height: 100%"}); aContainer.placeAt("markup")

然后destroyRecursive