我正在尝试为我的web应用程序中的地图开发一个内容样式小部件的表格。这些小工具在Chrome和FireFox中运行得非常好,但在Internet Explorer 8中无声无息(我在开发此应用程序时已经阅读过很多次了)。构建生命周期的BuildRendering和PostCreate方法。该小部件是使用图结构创建的,因此它是递归的。有没有人有任何想法可以导致小部件生命周期的这两种方法之间的失败?Dojo小工具 - BuildRendering和PostCreate之间的无声失败
我在某些地方看过这个模板可能是个问题,所以我将它包含在我的节点代码中。
这里的小部件的简化版本,所以你也许可以得到所发生的事情的想法:
define(['dojo/_base/declare', "dijit/_WidgetBase", "dijit/_TemplatedMixin",
"dijit/_WidgetsInTemplateMixin", "dojo/text!./templates/_Node.html"],
function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, template) {
var _Node = declare ([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString : template,
_childNodes : [],
constructor : function (params, srcNodeRef) {
lang.mixin(this, params);
this.inherited(arguments);
},
buildRendering: function(){
this.inherited(arguments);
// Execution leaves this function but never launches postCreate()
// buildRendering is not actually there in my code, I just have it here for
// debugging this particular problem.
},
postCreate : function() {
// Execution never reaches this point in IE8 (probably 7 and 9 as well)
var newParams = {
"Para1": "Value1",
"Para2": "Value2"
}
var newNode = new Node(newParams, this.containerNode);
this._childNodes.push(newNode);
}
});
return _Node;
});
而且这里是它的使用模板:
<div>
<div data-dojo-attach-point="rowNode" data-dojo-attach-event="onclick:_onClick">
<span data-dojo-attach-point="contentNode">
<span data-dojo-attach-point="checkContainerNode"></span>
<img src="${_blankGif}" alt="" data-dojo-attach-point="iconNode">
<span data-dojo-attach-point="labelNode"></span>
</span>
</div>
<div data-dojo-attach-point="containerNode" style="display: none;"></div>
</div>
所以我的节点遵循这一结构,但就像我说的,在Internet Explorer中buildRendering和postCreate之间默默无闻。我已经花了很多时间了。我希望有人能在这里帮我一把。
请不要看太多的语法,我复制我的代码的粘贴部分,但为了清晰起见,我对其进行了大量修改。
感谢,
Ggilmann
我不能说我的答案会解决您的问题,但我只列出了一些我在查看代码时注意到的事情。 – 2013-03-06 00:57:47
我已经复制了你的代码,并在Firefox和IE8中运行它,它似乎在两者中都完美运行。已经尝试运行在IE7模式,怪癖模式,兼容模式等等,都工作。我猜测什么是突破这是没有包括在上面的修改版本。我敢打赌,模板中的某些东西正在破坏它,因为在buildRendering期间这些东西正在被提取和包含。试图通过不包含_onClick()类方法或_blankGif属性来破解它,但这些在IE8中没有特别的破坏性。 – 2013-03-06 08:45:07