second_ffgf
second_ffgf

Reputation: 31

initialization of dojo widget

I tried to create custom widget for my site. when I loaded page it says: mixin #0 is not a callable constructor. clsInfo.cls.prototype is undefined I can't find any information about clsInfo, so I don't know what is it. maybe the problem that I use dojo from google:

and my own script is located on localhost. so when my dojo on page initializes something goes wrong with my script. I can't find any good info on dojo, maybe I search in wrong places? please help me to resolve my problem

Upvotes: 3

Views: 4428

Answers (3)

Steve
Steve

Reputation: 26124

I've run into this problem when I screw up the order of my requires which makes _WidgetBase not what _WidgetBase really is. Seems like a simple spot to screw up.

Upvotes: 0

brokenbeatnik
brokenbeatnik

Reputation: 730

I ran into this when I was trying to override a dijit.Dialog so I could bind events to controls within it. We've yet to see if the binding part will work, but if you look at the source, this happens when one of the bases passed in as the second argument fails to resolve to an "[Object function]". In my case, I was passing a String in.

dojo.declare takes 3 arguments:

  • The name of the custom object "class" you're building
  • An array of base classes, parents to provide functionality (not the string names of those classes)
  • A hash of functions and declarations

So if I want to override dijit.Dialog, I have to do:

dojo.declare("myDialogType", [dijit.Dialog], {
    function1() {/*Code*/},
    function2() {/*Code*/}
}

I had ["dijit.Dialog"] as my second argument and that was the problem.

I strongly recommend using Web Inspector or Firebug with uncompressed local copies of the Dojo library rather than the CDN to figure out what's going on and debug these types of problems. Dojo's documentation is extensive but not complete in some areas and some behaviors have to be figured out by looking at what the code expects. That's not intended as a slight to the authors; once you get it going it's a pretty awesome product, and any documentation for volunteer work is appreciated.

Upvotes: 3

mwilcox
mwilcox

Reputation: 4132

Are you sure Dojo is loading? Did you put your code in a dojo.addOnLoad()? When using a CDN you sometimes run into issues with execution times. dojo.addOnLoad() will not only trigger when the DOM is loaded, it gets called when dojo resources have downloaded, such as dijit._Widget.

Upvotes: 0

Related Questions