2

Dojo and iWidgets by IBM:
so my iWidget code is as follows:

onEdit : function() {

                    dojo.require(["dijit/Dialog", "dojo/dom"], function(Dialog, dom){
                        var node = dom.byId("makeADialog");
                        var myDialog = new Dialog({ title:"From Source Node" }, node);
                        myDialog.show();
                    });


                },

when i run this - chrome browser console shows:

   com.ibm.mm.iwidget.widget.IWidgetWrapperExtendedImpl     IWidgetWrapper._handleEventInternal: widget: testWidget, eventName: onedit, HandleEventException: TypeError: Object [object Array] has no method 'split'

whats wrong?

Sergey
  • 21
  • 7
  • I would use a javascript debugger to take a look at the callstack where the error occurs. Since you mentioned chrome - you can set "break on error" by opening the sources panel and clicking the pause button in the lower left. I'm totally guessing here, but I suspect you are using the legacy `dojo.require` as if it were the newer AMD `require`. `dojo.require` only expects a single string argument, and is synchronous, among other differences. You should probably check which version of dojo you are using, and if you want the AMD `require`, just use `require`. – Frances McMullin Apr 29 '13 at 12:34
  • I have 1.8.3 in my Eclipce IDE and ooops! 1.4.3_IBM (21629) in IBM universal test client for iWidget and Business Space runtime respectively. So what am i gonna do now? – Sergey Apr 29 '13 at 13:53
  • That is entirely up to you, the obvious options are to change your code so it works with dojo 1.4.3, or to try and change your environment somehow so it loads a newer version of dojo. – Frances McMullin Apr 29 '13 at 14:47

1 Answers1

0

As mentioned in the comments, the problem lies with your syntax. Since you're using the old way of including modules (dojo.require()), it also means you have to use the old syntax, not the new one.

This means that you should write your code as following:

onEdit : function() {
  var Dialog = dojo.require("dijit.Dialog");
  var node = dojo.byId("makeADialog");
  var myDialog = new Dialog({
    title: "From Source Node"
  }, node);
  myDialog.show();
},
g00glen00b
  • 41,995
  • 13
  • 95
  • 133