I am trying to have a commonBase object which will be extended by many classes. but during loading itself, i am have a problem with construtor while my page is loaded.
My commonBase.js is
define(
["dojo/_base/declare","dojox/gfx",
"dojox/gfx/shape","dojo/_base/lang"
], function(declare, gfx, shape, lang){
var commonBase = declare([], {
className:"commonbase",
x:0,
y:0,
constructor : function() {
console.log("Created commonBase obj.");
},
//some more methods.
});
});
and my inherited class is shelf.js
define([
"dojo/_base/declare","dojo/_base/lang",
"view/commonBase"
],
function(declare, lang, commonBase){
//var shelf =
return declare("view.shelf",[commonBase], {
//className:"shelf",
constructor: function(){
//declare.safeMixin(this,args);
console.log("shelf");
this.className = "shelf";
}
});
});
i am getting Uncaught Error: declare view.shelf: mixin #0 is not a callable constructor. dojo.js:6917
i even tried to call this.inherited() and declare.safeMixin(). but in vain.
This error is occuring during the load of the page. i understand that this is not even trying to access this object. I see in the console stack trace,it happens during some guardCheckComplete phase in dojo loader.
You need to return commonBase
after you define it with declare
. The return value of the callback in commonBase.js
is what is returned in callbacks that require
or define
commonBase
.
var commonBase = declare([], {
className:"commonbase",
x:0,
y:0,
constructor : function() {
console.log("Created commonBase obj.");
},
//some more methods.
});
return commonBase;