It's all about the answers!

Ask a question

How to create Widgets with AMD Dojo/JS

Jonas Studer (207917) | asked Sep 04 '14, 4:07 a.m.
edited Sep 05 '14, 3:08 a.m. by Ralph Schoon (62.9k33645)
Hy there fellas,

I've wanted to change my old dojo into the new AMD notations but I have a hard struggle on that.
I don't really get the new "define/require" logic from there....
By the way, I am creating RTC Widgets.

But let me Explain first:
1: You need a plugin entry with the name of your widget.
Kinda like. newWidgets.myWidget

2: In the old fashioned way I've just did the provide/declare thing.
(function() {
     //This is the RTC-Wiget superclass to inherit from
     var Viewlet =;
     var MyOtherWidget = newWidgets.myOtherWidget;
    //Again the name of myWidget
    dojo.declare("newWidgets.myWidget", Viewlet, {
       //Under here I can easy instantiate the MyOtherWidget with new

3: with the new AMD Logic I can't require other Classes (Only the Viewlet superclass works)
], function(declare, template) {
    var Viewlet =;
    return declare(newWidgets.myWidget", Viewlet , {
        templateString: template,

4: So my question is, where in this definte thing, can I use "myOtherWidget" or require it to instanstiate?
The Internet told me:
require = use modules
define = define modules
But why can't I use require INSIDE a define?

One answer

permanent link
Jonas Studer (207917) | answered Jan 14 '16, 7:38 a.m.
Solutions here:

Your answer

Register or to post your answer.