如何使用数组的长度来创建Accordion中的子项数。例如,如果数组的长度是8,我会从手风琴中创建8个孩子。 Dojo新手。
答案 0 :(得分:3)
假设dataArrray是一个包含contentpane数据的对象数组。
require(["dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dojo/domReady!"],
function(AccordionContainer, ContentPane){
var aContainer = new AccordionContainer({style:"height: 300px"}, "markup");
len = dataArray.length;
for ( var i =0; i<len; i++);
{
aContainer.addChild(new ContentPane({
title:dataArray[i].title,
content: dataArray[i].content
}));
}
aContainer.startup();
});
答案 1 :(得分:1)
您需要将内容添加到内容窗格中。
require(["dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dojo/domReady!"],
function(AccordionContainer, ContentPane){
var acc = new AccordionContainer();
for(var i = 0; i < arr.length; i++) {
acc.addChild(new ContentPane());
}
});