[Dojo-interest] TitlePane methods

Daniel daniel.carrera at zmsl.com
Tue Dec 11 21:39:54 UTC 2007


Hello,

Say I have a title pane:

<div dojoType="dijit.TitlePane" title="Foo" id="Foo"></div>

And I want to put a tree widget inside it. This is one way I could do it:

dijit.byId("Foo").setContent("<div id='Bar'></div>");
var tree = new dijit.Tree({
		store:store,
		labelAttr:'name',
		typeAttr:'type',
		query:{ type: "category" }
	}, "Bar"
);

This works, but I don't like .setContent("<div id='Bar'></div>"). It 
feels too much like the hand-made HTML that makes my current program 
awkward and hard to maintain. I would rather do something like:

var tree = new dijit.Tree({
		store:store,
		labelAttr:'name',
		typeAttr:'type',
		query:{ type: "category" }
	});
dijit.byId("Foo").setContent(tree);


But that doesn't work. setContent wants a string. And TitlePane doesn't 
have addChild() or appendChild().


Is there a way to add the tree to the title pane that avoids writing 
hand-made HTML from JavaScript? This is not necessary to get it working. 
It's more of a personal preference. I want to separate markup and JS. 
I'd rather not see any markup in a .js file or any JavaScript in a .html 
file.

Thanks for the help.


Daniel.


More information about the Dojo-interest mailing list