Dojo Dialog.show()不起作用

时间:2014-03-14 11:34:11

标签: javascript rest dojo

我想在Dojo Selectbox(dijit.form.select)中显示JSONRest中的JSON。因此,我有以下代码:

    var processStore = new JsonRest({
                target: "http://cnwin.ebusiness.local/activiti-rest/service/repository/process-definitions?startableByUser=kermit", 
                headers: {"Authorization": "Basic a2VybWl0Omtlcm1pdA=="}, 
                allowNoTrailingSlash: false
                });

var myWidget = dijit.byId("processList");
myWidget.setStore(processStore);
this.show();

This是一个dijit / Dialog。此代码工作正常,并显示对话框。但REST-Call是异步的。当我在此代码块中添加以下方法时,行this.show()不再起作用:

    var processStore = new JsonRest({
    target: "http://cnwin.ebusiness.local/activiti-rest/service/repository/process-definitions?startableByUser=kermit", 
    headers: {"Authorization": "Basic a2VybWl0Omtlcm1pdA=="}, 
    allowNoTrailingSlash: false
    });

processStore.query().then(function(response){
var myWidget = dijit.byId("processList");
    myWidget.setStore(processStore);
    this.show();
}

使用printlns,我可以看到所有命令都被执行,除了最后一个(this.show()) 有没有想法?

感谢您的回答和问候 本

1 个答案:

答案 0 :(得分:2)

我认为this.show()不再在对话框的范围内。

您可能需要尝试以下操作:

var processStore = new JsonRest({
    target: "http://cnwin.ebusiness.local/activiti-rest/service/repository/process-definitions?startableByUser=kermit", 
    headers: {"Authorization": "Basic a2VybWl0Omtlcm1pdA=="}, 
    allowNoTrailingSlash: false
});

var self = this;  // You can keep the scope of this saved
processStore.query().then(function(response){
    var myWidget = dijit.byId("processList");
    myWidget.setStore(processStore);
    self.show();  // Now self points to the dialog box
}

通过添加var self = this;然后在函数中使用self.show(),self应该是对话框。