Reputation: 1599
I want to display JSON from a JsonRest within a Dojo Selectbox (dijit.form.select). Therefore, i have the following code:
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
is a dijit/Dialog. This code works fine and the Dialog is displayed. But the REST-Call is asynchronous. When I add the following method arround this code block, the line this.show()
does not work anymore:
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();
}
With printlns, I could see that all commands are executed except the last one (this.show()
)
Has onyone an idea?
Thanks for your answers and best regards Ben
Upvotes: 0
Views: 232
Reputation: 156
I think that the this.show() is no longer within the scope of the dialog box.
You may want to try the following:
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
}
By adding the var self = this; and then using self.show() in the function, the self should be the dialog box.
Upvotes: 2