views:

47

answers:

1

Zend framework adds the dojo.parser.parse(); to your script if you have widgets on the page, but not if you don't - makes sense. But I have a common js file which should set up lightbox images within all pages, and for this i need dojo.parser.parse(); to be included. I can add it to my common js file, but if I do, the parser runs twice and dojo breaks because all widgets in the page are getting added twice.

How can I set my js up to effectively look for unparsed items, or even better, would be to detect if dojo.parser.parse(); has already been run? (Unfortunately Zend doesn't assign the dojo.parser.parse(); to a variable)

A: 

Once dojo.parser.parse() has finished the parsing of widgets, all the widgets references can be found at the global object dijit.registry._hash. You can use a simple test to check whether this object is empty to determine whether dojo.parser.parse() has been called.

This approach only works when you only create widgets declaratively.

Alex Cheng