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 thi开发者_运维技巧s 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.
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
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");
}
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");
Well, if you wrap that code with a dojo.addOnLoad()
function call you should be good.
http://dojotoolkit.org/reference-guide/dojo/addOnLoad.html
精彩评论