[Dojo-interest] Declaring and accessing multiple widgets in one single widget file

Mike Wilcox mike at mikewilcox.net
Thu Mar 18 07:45:23 EDT 2010


Try:

dojo.provide("widgets._MultiTextBase");
dojo.declare("widgets._MultiTextBase", .... )

All your other widgets should also be in the widgets namespace, but you don't need more than that first provide. dijit.form.Button has multiple declares in it. The system will see the objects are already available and not try to load additional files.

Mike

On Mar 18, 2010, at 3:35 AM, abhi wrote:

> Hi Folks,
> 
> I have a set of really small widgets that I use in my app that have a 
> common base class which I put in a single js file. It looks something 
> like this:
> 
> dojo.declare("_MultiTextBase",[dijit._Widget, dijit._Templated],{ ...
> dojo.declare("MultiTextBox",_MultiTextBase,{ ...
> dojo.declare("MultiTextArea",_MultiTextBase,{ ...
> dojo.declare("MultiEmailBox",_MultiTextBase,{ ...
> dojo.declare("MegaBytesNumberBox", dijit.form.NumberTextBox, { ...
> 
> Now, in my index.html, I have the following:
> 
> dojo.registerModulePath("widgets", "/widgets");
> 
> and I would like to pull in the widgets, as usual:
> 
> dojo.require("widgets.MultiTextArea");
> dojo.require("widgets.MultiTextBox");
> dojo.require("widgets.MultiEmailBox");
> dojo.require("widgets.MegaBytesNumberBox");
> 
> but I get a 404 because it is accessing the individual widgets as js 
> files. I don't want to separate them into individual files. I was hoping 
> to do something like dijit.form.button.js which declares multiple button 
> widgets.
> 
> Regards,
> Abhi
> 
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://docs.dojocampus.org
> Dojo-interest at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



More information about the Dojo-interest mailing list