admin管理员组

文章数量:1313750

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.

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.

Share Improve this question edited Aug 18, 2019 at 11:39 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 30, 2011 at 16:47 AyyoudyAyyoudy 3,72112 gold badges49 silver badges66 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

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 plete!");
});
myCp.set("href", "myHtml.html");

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

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

本文标签: javascriptDojo on widget load eventStack Overflow