Reputation: 8026
I have the following subclass, derived from ContentPane:
define([
"dijit/layout/ContentPane",
"dojo/_base/declare"
],
function (ContentPane, declare) {
var view = declare("client.View", ContentPane, {
html: null,
constructor: function (args) {
declare.safeMixin(this, args);
if (this.html !== null) {
this.set("content", this.html);
}
}
});
return view;
}
);
Now, the following code throws TypeError on "this.set("content", this.html);" line:
var html = "<div>Hello</div>";
var view = View(html);
How should I set content of a ContentPane properly?
Upvotes: 0
Views: 958
Reputation: 8026
Ken Benjamin answered my question on Dojo Community (http://dojotoolkit.org/community/):
You are trying to set the content too early in the widget lifecycle. Try doing it in postCreate instead of constructor.
Read more about the widget lifecycle here: http://dojotoolkit.org/documentation/tutorials/1.6/understanding_widget/
Upvotes: 1