且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式向现有AccordionContainer添加新的Dojo AccordionPane

更新时间:2023-11-30 17:24:16

由于原创海报表示,为AccordionContainer的 TOP 添加新的AccordionPane,将 insertIndex
如果您希望将新的AccordionPanel添加到AccordionContainer的 BOTTOM ,只需从.addChild中删除 insertIndex ,如下所示:

As the original poster said, to add the new AccordionPane to the TOP of the AccordionContainer, use 0 for the insertIndex. If you'd rather add the new AccordionPanel to the BOTTOM of the AccordionContainer, just remove the insertIndex from the .addChild as seen below:

        function Testing() {
            var accordion = dijit.byId("myacc"); 
            var d = new dijit.layout.AccordionPane({id:'newpane', title:'hello', content: 'testing'}); 
            accordion.addChild(d); 
            accordion.selectChild(dijit.byId('newpane'));
        }

此外,在我的情况下,我想要添加一个新的AccordionPane到AccordionContainer内容从同一台服务器上的另一个页面加载。以下代码可供将来想找到相同的人:

Also, in my case I was wanting to add a new AccordionPane to the AccordionContainer with content loaded from another page on the same server. Code below for anyone who finds this in the future wanting to do the same:

        function Testing() {
            var accordion = dijit.byId("myacc"); 
            var d = new dijit.layout.AccordionPane({id:'newpane', title:'hello', href: "location/of/page.php", preload: true}); 
            accordion.addChild(d); 
            accordion.selectChild(dijit.byId('newpane'));
        }

另外,如果要在选择孩子时启用动画,请添加 true 动画属性:

Also, if you want to enable animation when selecting the child, add true to the animate property:

            accordion.selectChild(dijit.byId('newpane'), true);