As I wanted to minimize the number of files included at runtime in my prior piece, I tried to narrow down my dojo.require() statements. Do this after you have done cross-browser testing!
In including only dojo.event.connect, Firefox was running beautifully. I tried in IE6 and all of a sudden the event objects being returned were undefined! Because IE’s event object is different than Firefox, Dojo runs a fixEvent() method before passing it back to your callback function. Because I had only included dojo.event.connect(), dojo.event.fixEvent() was not being run and my object was coming back undefined and empty.
Two more tips on debugging Dojo.require():
- If you have Firebug installed (for FF), you can tell it to show you all network requests and that will show you Dojo trying to use the package system and load libraries. You can look at the header response for each GET and see when it tries to request something that isn’t there (and then Dojo will try to back up the directory tree to find a match).
- Check your server log files for 404 requests. This can tell you you’re requiring something that doesn’t exist. In these cases, you may need to adjust your dojo.require() calls from say dojo.require(“dojo.lfx.html.*”) (which doesn’t exist and returns a 404) to dojo.require(“dojo.lfx.html”) which does exist. Both of them will work, because Dojo’s package system is smart enough to first check for dojo/lfx/html/* and then for dojo/lfx/html but the latter is faster (fewer attempts). Same thing with dojo.html.getElementsByClass – this wasn’t actually working but the package system was backing up to find dojo.html which made it seem to work but it required extra steps.
Develop first, optimize second. Dojo does all kinds of tricks on your behalf so make sure you test cross-browser while you’re optimizing.
Ramdas said:
on April 18, 2007 at 2:57 am
Good job.. i am waiting for some more dojo stuff… Thanks