- The Book of Dojo
- The Dojo Book, 0.4
- Part 1: "Introduction"
- Part 2: "Out of the Box" Dojo
- Part 3: "The Dojo Programming Model"
- Part 4: "More on Widgets"
- Part 5: "Connecting the pieces"
- Part 6: "Customizing Dojo Builds for Better Performance"
- Part 7: "Utilities"
- Part 8: "Internationalization and Accessiblity"
- Part 9: "Dojo Community"
- Part 10: "Fresh From The Shed" Dojo
- BookWriting
- Glossary
Compound Widgets
Submitted by bill on Fri, 12/08/2006 - 22:46.
TODO: moved this from "The Memo" page, where it definitely didn't belong, but it could use some expansion
This is a crucial next step for widget authors - creating widgets which themselves contain inner widgets, resulting in what we could call 'compound widgets'.
The procedure is simple, just add to your widget .js file, within the widget atributes object, the line:
widgetsInTemplate:true,
then, your subwidgets will nest perfectly within the main outer widget. You should also be able to nest to any arbitrary depth. Just remember though to abstain from setting the id or dojoId attributes in your html, rather set dojoAttachPoint instead to insert into your main outer widget a named attribute which references your subwidget. This way, you won't pollute the global element namespace. Otherwise, you'll hit problems if creating multiple instances of your compound widgets.
The Monolithic App Widget
One approach to dojo application design is to build the app as one huge compound uber-widget, containing all the needed sub-widgets.This approach will likely have a natural feel and appeal to those experienced in desktop GUI programming.
If you want to go in this direction, then your app can get loaded in the client by a very minimal HTML file which just pulls in a minimal stylesheet, includes dojo.js, dojo.require()s your main app widget, then invokes that widget in a single
tag within your document . There are those of us who feel that the less javascript code you have within html files, the better!
