Reputation: 4647
I sometimes see two slightly different ways to when using declare
in dojo:
way one is
define(["dojo/_base/declare"], function(declare){
return declare(null, {
constructor: function(){
}
});
which contrasts
define(["dojo/_base/declare"], function(declare){
return declare("some/string/with/slashes/parameter",null, {
constructor: function(){
}
});
I would like to know what the reason for the "some/string/with/slashes/parameter"
in the second version is about?
Does a module/"dojo class" need to name itself, or is the nameing not always implied by its filename?
Upvotes: 1
Views: 122
Reputation: 14712
This first declaration will create an anonymous class ( availble withing its scope only ) so to access this last you you should make acces to it or its package in the dojoConfig global var ,
For the seconde declaration this last , is being created in the global scope ( app scope ) , so it can be instantiated or used using its declared class name some.string.with.slashes.parameter
(recomanded to use dots insted of slash) that define generaly the name space conataing this class + class name.
Not that in the dojo documentation :
Named classes should only be created if they will be used with the Dojo parser. All other classes should omit the className parameter.
this means using the second declaration only for widgets or class used withing dojo/parser
like creating a custom declartion of Button (ovveride or extend ) ...
Upvotes: 2