0
我有一個自定義小部件無法正常工作。它正在被實例化,但它不會調用postCreate
函數。我沒有收到任何錯誤消息。dojo自定義小部件不會調用postCreate
我已刪除從窗口小部件用於測試目的的任何額外的代碼,這裏是生成的代碼:
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() {
}
});
});
我可以告訴它被實例化,因爲當我在Chrome的調試,我可以設置斷點行:templateString : template
,它將在該斷點處停止,但它不會停止在postCreate
函數內的代碼的斷點處。該模板本身是一個簡單的HTML文件,其中包含幾個div
和一個dojox.mobile.button
。
UPDATE:
下面是實例代碼:
require(["pgonline/widgets/AttributeInspector2"], function(AttributeInspector) {
var att = new AttributeInspector({});
att.placeAt("attributeInspector");
att.startup();
});
請問你的widget類實例化?解析器?編程? – BuffaloBuffalo 2013-04-11 15:33:01
@BuffaloBuffalo - 我添加了實例代碼的帖子。 – Brian 2013-04-11 15:38:08
你能在jsfiddle中模仿這種行爲嗎?我[設置這一個](http://jsfiddle.net/H7Zh8/39/)類似於你的(不同的事件處理程序和模塊,但相同的部件設置和實例化),並按預期工作。 – Default 2013-04-11 15:55:14