Opened 12 years ago

Closed 12 years ago

#11720 closed defect (invalid)

onLoad is never called if content is specified when creating a Dialog

Reported by: liucougar Owned by:
Priority: high Milestone: tbd
Component: Dijit Version: 1.5
Keywords: Cc:
Blocked By: Blocking:


try the following code with dijit trunk (r22861 atm)

<script src="../dojo/dojo.js"></script>
	dojo.declare('mydialog', dijit.Dialog,{
		content:"content is here", 
		onLoad: function(){
			console.log('onLoad is called');
		var d = new mydialog();;
<link href="../dijit/themes/tundra/tundra.css" type="text/css" rel="stylesheet"/>
<body class="tundra">

the console does not print 'onLoad is called'. While using r22770, that line is printed. This is a change of behavior, is it intended? (it can be easily workaround by moving the code from onLoad to postCreate, I just want to file this ticket to make sure the change of behavior is as expected)

Change History (1)

comment:1 Changed 12 years ago by bill

Resolution: invalid
Status: newclosed

This is from [22835], and the behavior change is intentional. Note that

<div dojoType=Dialog>...</div>

never called onLoad(), so the equivalent programmatic construct:

new dijit.Dialog({content:...})

shouldn't either. Calling onLoad() in either of the above test cases seems useless, like calling onChange() when a TextBox is initially created.

In ContentPane I wrote the comment:

	// For back-compat reasons, call onLoad() for set('content', ...)
	// calls but not for content specified in srcNodeRef (ie: <div dojoType=ContentPane>...</div>)
	// or as initialization parameter (ie: new ContentPane({content: ...})
	this.onLoadDeferred.addCallback(dojo.hitch(this, "onLoad"));

Note that technically the new behavior matches the spec of onLoad() in Dialog better:

onLoad: function(){
	// summary:
	//		Called when data has been loaded from an href.

... although it doesn't match it exactly since onLoad() is also called when data is set via set("content", ...).

Let me know if there's something I'm missing.

Note: See TracTickets for help on using tickets.