Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#737 closed defect (fixed)

addOnLoad() executes before widgets are instantiated

Reported by: bill Owned by: James Burke
Priority: high Milestone:
Component: General Version: 0.3
Keywords: Cc:
Blocked By: Blocking:

Description

This bug is just a reminder that James will checkin a bug fix to addOnLoad(), to make it work like in 0.2.2. Details from James:

There was a slight change: widget instantiation is just another addOnLoad registration and notification now, *if* all the packages have not loaded yet. It will be the first item in the onload notification queue.

I'm working on a change now that will allow people to add things to the end of the onload queue in code that is executing as part of on load queue notification.

In short, the code change should fix the issues brought up in this thread.

James

On 5/17/06, Bill Keese <bill@…> wrote:

James, I understand that addOnLoad() will fire immediately if it's called after the "load" is finished, but in 0.2.2, the definition of "load" included both loading packages and instantiating widgets. Was that changed?

Bill

James Burke wrote:

Before the page is loaded, any functions passed to dojo.addOnLoad() will get called after the window.onload() fires, and after any outstanding Dojo packages have loaded. That part hasn't changed since past releases.

The new behavior though is what happens when you add an onload listener via dojo.addOnLoad() *after* the page has loaded an all packages are loaded. Maybe "listener" is the wrong word -- I mean the function that you pass to dojo.addOnLoad() that will be called with the "on load" criteria have been met (see first paragraph).

If you call dojo.addOnLoad() *after* the window.onload has fired and all outstanding packages are loaded, the function passed to dojo.addOnLoad() will be called immediately. This change was done to allow xdomain loading to work with dojo.require() statements that are done after the page has initially loaded.

James

On 5/17/06, Jon Sykes <jon.sykes@…> wrote:

So when does addonLoad now fire?

Seems like a strange move away from what I would think was expected behavior.

I assume addonload was the dojo equivalent to adding onload="" to the body tag.

Jon Sykes

On May 17, 2006, at 1:17 PM, James Burke wrote:

dojo.addOnLoad was changed in 0.3, and that change is the cause of the behavior that you describe below.

You could get the behavior you are looking for by adding a dojo.addOnLoad() listener outside of your widget code. For instance, right after you finish doing all of the dojo.require() statements for your page.

Does that work?

James

On 5/17/06, Matthew Skomarovsky <mskomarovsky@…> wrote:

Has dojo.addOnLoad changed with the 0.3 release?

Certain functions I'm passing to it are being called before all my widgets are initialized, causing some problems, whereas a week ago it waited patiently until everything was loaded.

Specifically, I'm creating a series of widgets (via HTML), and in my first widget's postCreate method, I use dojo.addOnLoad to call a few of the other widgets' methods. This used to allow me not to worry about the widget creation order, since it would wait for all widgets to initialize before calling any of their methods. Now, the methods are being called before the widgets exist (or, at least, before they can be referred to with dojo.widget.byId).

Change History (2)

comment:1 Changed 13 years ago by James Burke

Resolution: fixed
Status: newclosed

Fixed in r4059

comment:2 Changed 12 years ago by (none)

Milestone: 0.3.1

Milestone 0.3.1 deleted

Note: See TracTickets for help on using tickets.