Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dojo 推迟道场_Dojo_Widget_Deferred - Fatal编程技术网

Dojo 推迟道场

Dojo 推迟道场,dojo,widget,deferred,Dojo,Widget,Deferred,从小部件中的方法获取延迟返回时,我遇到了一点问题。方法本身返回一个Deferred,因为它是xhrPost。代码是这样的(使用Dojo1.8) 呼叫代码: quorum = registry.byId("quorumPanel"); var deferredResponse = quorum.updateSelectionCount(); deferredResponse.then(function(data){ console.log("Success: ", data); },

从小部件中的方法获取延迟返回时,我遇到了一点问题。方法本身返回一个Deferred,因为它是xhrPost。代码是这样的(使用Dojo1.8)

呼叫代码:

quorum = registry.byId("quorumPanel");

var deferredResponse = quorum.updateSelectionCount();

deferredResponse.then(function(data){
    console.log("Success: ", data);
}, function(err){
    console.log("Error: ", err);
});
以及小部件中的代码:

updateSelectionCount: function() {

    var self = this;

    var deferredResponse = xhr.post({
        url: "ajxclwrp.php",
        content: [arguments here],
        handleAs: "json"});

    deferredResponse.then(function(response) {

    var anotherDeferred = new Deferred();

        var _boolA = true;
        var _boolB = true;
        dojo.forEach(response.result, function(relationshipInfo){
            [do a bunch of stuff here too set _boolA and/or _boolB]
        });

        self._sethasRequiredAttr(_hasRequired);
        self._setHasRequestedAttr(_hasRequested);
        self.quorumInfo.innerHTML = quorumHtml;

        // Below is not working 
        anotherDeferred.resolve('foo');
        return anotherDeferred;

    });

}
我是否需要建立另一个承诺并使用承诺/全部。在这一点上我感到困惑/沮丧

TIA.

the.then()方法返回另一个延迟。你只需要在里面放一个return语句

updateSelectionCount: function() {

    var self = this;

    var deferredResponse = xhr.post({
        url: "ajxclwrp.php",
        content: [arguments here],
        handleAs: "json"});

    return deferredResponse.then(function(response) {

        var _boolA = true;
        var _boolB = true;
        dojo.forEach(response.result, function(relationshipInfo){
            [do a bunch of stuff here too set _boolA and/or _boolB]
        });

        self._sethasRequiredAttr(_hasRequired);
        self._setHasRequestedAttr(_hasRequested);
        self.quorumInfo.innerHTML = quorumHtml;

        return "foo";
    });

}