Dojo : Accordion open and close
http://stackoverflow.com/questions/11734171/dojo-accordion-open-and-close
HTML
<div id="markup" style="width:300px; height: 300px"></div>
CSS
.dijitTitlePaneTitle{background:red;border:2px solid green;color:white;}
JavaScript
// Dojo 1.7+ (AMD)
require(["dojo/dom-construct", "dijit/TitlePane", "dijit/layout/ContentPane", "dojo/domReady!"
], function(domConstruct, TitlePane, ContentPane) {
//var aContainer = new AccordionContainer({style:"height: 300px"}, "markup");
var containerNode = dojo.byId("markup");
var a = new dijit.TitlePane({
title:"This is a title pane",
content: new ContentPane({
content:"Hi!",
style:"background:yellow"
})
}, domConstruct.create('div', {}, containerNode));
var b = new dijit.TitlePane({
title:"This is as well",
open: false,
content: new ContentPane({
content:"Hi how are you?",
style:"background:yellow"
})
}, domConstruct.create('div', {}, containerNode));
var c = new dijit.TitlePane({
title:"This too",
open: false,
content: new ContentPane({
href:"https://www.google.co.in/",
parseOnLoad:true,
refreshOnShow:true,
closable:true,
style:"background:yellow"
})
}, domConstruct.create('div', {}, containerNode));
var panes = [a,b,c];
var fnOnOpen = function() {
dojo.forEach(panes, function(p) {
if (p !== this && p.get('open')) {
p.toggle();
}
});
};
dojo.forEach(panes, function(p) {
p.startup();
p.connect(p, '_onShow', fnOnOpen);
});
});