我正在嘗試爲我的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