Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to create Widgets with AMD Dojo/JS

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?

0 votes



One answer

Permanent link
Solutions here:

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

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Sep 04 '14, 4:07 a.m.

Question was seen: 3,289 times

Last updated: Jan 14 '16, 7:38 a.m.

Confirmation Cancel Confirm