Ayyoudy
Ayyoudy

Reputation: 3721

Dojo on widget load event

I'd like to know when a Dojo form widget is parsed or ready so I can customize it dynamically. I am trying to achieve this by using the dojo.connect() method. However, I am not sure what event to listen to. Is it onLoad or onStartup or..?

This is what I have done but it isn't triggering:

dojo.connect(dijit.byId('myWidget'), 'onStartup', function(evt) {
   console.debug("test");
}

note that the dijit.byId('myWidget') part returns the object correctly so that isn't the problem.

Upvotes: 5

Views: 4216

Answers (4)

Robin Wieruch
Robin Wieruch

Reputation: 15898

In my case I needed to wait for an external template. I made it like this:

var myCp= registry.byId("myContentPane");
myCp.set("onDownloadEnd", function(){
    console.log("Download complete!");
});
myCp.set("href", "myHtml.html");

Upvotes: 1

Ayyoudy
Ayyoudy

Reputation: 3721

to answer my own question, there is a "startup" function in the widget lifecycle so I can use that instead of "onStartup" like so:

dojo.connect(dijit.byId('myWidget'), 'startup', function(evt) {
   console.debug("test");
}

Upvotes: 2

Alex.Bullard
Alex.Bullard

Reputation: 5563

It depends somewhat on what exactly you are trying to customize (see the widget lifecycle here) but I would guess that connecting to postCreate will satisfy your requirements

Upvotes: 3

DanMan
DanMan

Reputation: 11561

Well, if you wrap that code with a dojo.addOnLoad() function call you should be good.

http://dojotoolkit.org/reference-guide/dojo/addOnLoad.html

Upvotes: 0

Related Questions