1
我有類似於下面的代碼使用Dojo一些問題推遲: -this.watch沒有得到所謂的deferred.then()
這是XXX.js文件
dojo.declare('XXX', [dijit._Widget, dijit._Templated], {
postCreate: function() {
//getting deferred from somewhere
var _this = this;
deferred.then(function(response) {
console.log("This is getting printed");
_this.watch("value", function(A, B, C) {
console.log("This is not getting printed");
var value = _this.get("value");
_this.onValueChange(value);
});
}
我把這個類形式的其他JS FLE與下面的代碼: -
this.object = new XXX({
//some args
}
dojo.connect(this.object, "onValueChange", function(value) {
console.log("I am here");
this.onValueChange(value);
});
當我使用相同的「看」不deferred.then,這是工作完全正常,但現在它不執行該功能時,我在形式上改變值。任何指針? 難道是因爲當我的「this.object」被創建時,延遲沒有執行「then」中的函數?
'deferred.then'中的處理程序可能未被調用,您是否介意添加實際的延遲對象接受/拒絕標準的代碼? –
我可以打印任何超過this.watch並延遲的內容。對不起,由於與我公司的隱私協議,將無法提供實際的代碼。但是,這段代碼是在postCreate()方法中,遵循如下的生命週期: - https://dojotoolkit.org/reference-guide/1.9/dijit/_WidgetBase.html#id5 – DexterMorgan
然後創建一個簡化的案例,最好是一個小提琴。如果你沒有辦法,我們無法幫助你,因爲問題不在你上面發佈的代碼中,上面'.then'中的代碼不會根據你的名字被調用,這意味着延遲被拒絕。沒有延期接受代碼 - 沒有答案。 –