OK, here are my assumptions about what you're trying to do:
- You don't really need a global variable called
some
with a propertyvar
, that's just a way to organize stuff - You want three modules,
some/var/iable
,some/var/iable2
, andblah
. This means three files and threedefine()
calls - Neither
som.var.iable
norsom.var.iable2
are real inheritable classes, they're just plain old objects... so onlyblah
needs to usedeclare()
Thus you should create a file som/var/iable.js
, which is a provides a plain object:
define([
],
function(){
return {A:1,B,2}
});
And another called som/var/iable2.js
, which is a module that provides a plain object:
define([
"som/var/iable",
],
function(iable){
return {C: 3, D:iable.B}
});
And then your third module blah.js
that provides a Class-object:
define([
"dojo/_base/declare",
"som/var/iable2"
],
function(declare,iable2){
var parentClasses = [];
var clazz = declare(parentClasses, {
constructor : function(){
// No need for this.inherited(arguments) in this particular case
alert("Welcome to the constructor. Did you know that iable2.D is "+iable2.D+"?");
},
});
return clazz;
});
I haven't tested all this, but to kick it off in a page you'd finally want to put:
require(["blah",dojo/domReady!"], function(blah){
var b = new blah();
});
Dojo should take care of loading everything in-order so that you get an alert that says
Welcome to the constructor. Did you know that iable2.D is 2?