views:

172

answers:

1

I am trying to create an object and then call dijit.getViewport from inside a function, but I keep getting an error in firebug which I dont quite understand. I have stripped the object right down to the bare minimum to try and understand where is going wrong. this is what I am left with:

"use strict";

dojo.provide("local.mods.Builder");

dojo.require("dijit.dijit");

var Builder = {};

Builder.initialize = function () { console.log("Builder initialized."); var vp = dijit.getViewport(); };

Builder.initialize();

I am sure I am probably doing something silly here involving scope, but I can't quite put my finger on it, the error I get is this:

failed loading js/dojo/../local/mods/Builder.js with error: TypeError: _b is undefined [Break on this error] (undefined out of range 16) Could not load 'local.mods.Builder'; last tried '../local/mods/Builder.js' [Break on this error] (function(){var _1=null;if((_1||(typeof ....setTimeout(dojo._loadInit,1000);}})();\n

If I take out the line 'var vp = dijit.getViewport();', then the module loads fine so I know there is no problem with the loading.

Please help!

+1  A: 

Figured it out now, I used dojo.addOnLoad(Builder.initialize) instead of Builder.initialize().