views:

24

answers:

1

I found that Dojo has the most awesome and unappreciated feature - Declarative widget instantiations/layouts. This is the type of instantiation where you create the widget with raw html, and don't need any javascript (simply by specifying the dojoType attribute). (I discovered this by following this awesome (although horribly css'ed) tutorial on Dojo http://www.taubler.com/articles/article_Create_a_Custom_Javascript_AJAX_Widget_with_Dojo?id=5

But the question is, how do I retrieve these widgets after they are instantiated in the web page?

+2  A: 

Usually you give your widget an ID so you can access it afterwards via dijit.byId(). See here for dijit basics: http://www.dojotoolkit.org/reference-guide/dijit/info.html#dijit-basics

And yes, declarative syntax does make your static HTML invalid, which isn't ideal. But AFAIK the HTML spec says that unknown attributes should be ignored by parsers, so it's still ok - i guess. Especially in the beginning when you're still learning, as you get results more quickly. The goal should be to do it programmatically though, IMHO. If only for separation of logic and presentation.

DanMan