Login Register

Compound Widgets

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!