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 (63.1k33645)
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.
dojo.provide("newWidgets.myWidget");
//Requirements
dojo.require("newWidgets.myOtherWidget");
(function() {
     //This is the RTC-Wiget superclass to inherit from
     var Viewlet = com.ibm.team.dashboard.web.ui.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)
define([
    "dojo/_base/declare",
    "dojo/text!myTemplate",
    "dojo/domReady!",
], function(declare, template) {
    var Viewlet = com.ibm.team.dashboard.web.ui.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:

https://jazz.net/forum/questions/171336/modern-dojoamd-notation-causing-troubles-widget-creation-with-ibm-modules

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.