Reputation: 2800
I have a custom widget that is not working properly. It is being instantiated, but it will not call the postCreate
function. I do not receive any error messages.
I have removed any extra code from the widget for testing purposes and here is the resulting code:
define(["dojo/_base/declare",
"dojo/_base/lang",
"dijit/_WidgetBase",
"dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin",
"dojox/mobile/Button",
"dojo/text!pgonline/widgets/AttributeInspector/templates/AttributeInspector.html"],
function(declare,
lang,
_WidgetBase,
_TemplatedMixin,
_WidgetsInTemplateMixin,
Button,
template) {
return declare("AttributeInspector2", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString : template,
baseClass : "AttributeInspector2",
postCreate : function() {
dojo.connect(this, "onBeforeTransitionIn", lang.hitch(this, this.onPageLoad));
},
onPageLoad : function() {
}
});
});
I can tell it is being instantiated because when I debug in Chrome, I can set a breakpoint on the line: templateString : template
and it will stop on that breakpoint, but it will not stop on the breakpoint for the code inside the postCreate
function. The template itself is a simple HTML file that contains several div
's and a single dojox.mobile.button
.
UPDATE:
Here is the instantiation code:
require(["pgonline/widgets/AttributeInspector2"], function(AttributeInspector) {
var att = new AttributeInspector({});
att.placeAt("attributeInspector");
att.startup();
});
Upvotes: 0
Views: 1466
Reputation: 7852
This might be off base, but based on your fiddle, the error in the console is Uncaught Error: Invalid template
Your template looks like this:
<div>
<button data-dojo-attach-point='prevButton' data-dojo-type='dojox.mobile.Button'></button>
<button data-dojo-attach-point='nextButton'></button>
</div>
<div data-dojo-attach-point='attributes'></div>
Dijit requires templates to have a single root node-- so as a fix, just add a containing div to the template
<div>
<div>
<button data-dojo-attach-point='prevButton' data-dojo-type='dojox.mobile.Button'></button>
<button data-dojo-attach-point='nextButton'></button>
</div>
<div data-dojo-attach-point='attributes'></div>
</div>
Upvotes: 2