LeonM
10 Oct 2012, 7:33 AM
I use Ext.direct to implement a third party API. The server configuration (list of exposed methods to the client) gets downloaded through AJAX, like this:
Ext.Ajax.request({
url: 'http://my.api.com/api/',
success: function (response, opts) {
var api_specs = Ext.decode(response.responseText);
Ext.direct.Manager.addProvider({
type: 'direct',
namespace: 'my_api',
url: 'http://my.api.com/api/',
actions: api_specs
});
}});
The problem here is that the API specification is loaded asynchronously, so whenever I try to use the API, like this:
xtype: 'form',
api: {
submit: 'my_api.user.login'
}
I get an error, because Ext tries to instantiate the form before the API method specification finishes loading.
So, I am looking for some way to 'delay' the instantiation of my app until the API is fully loaded. In Ext3 I would probably fire an event after the API loads and then nest a listener within Ext.onReady() or something like that, but I'm not sure how to do it in Ext4...
According to the docs, Ext.Application() gets launched "after the page is ready", so I guess that is the same as good old Ext.onReady()? So maybe I could somehow alter this behavior to launch it after the page is ready AND my API is loaded?
Or can I use the Ext.loader in some way perhaps?
Ext.Ajax.request({
url: 'http://my.api.com/api/',
success: function (response, opts) {
var api_specs = Ext.decode(response.responseText);
Ext.direct.Manager.addProvider({
type: 'direct',
namespace: 'my_api',
url: 'http://my.api.com/api/',
actions: api_specs
});
}});
The problem here is that the API specification is loaded asynchronously, so whenever I try to use the API, like this:
xtype: 'form',
api: {
submit: 'my_api.user.login'
}
I get an error, because Ext tries to instantiate the form before the API method specification finishes loading.
So, I am looking for some way to 'delay' the instantiation of my app until the API is fully loaded. In Ext3 I would probably fire an event after the API loads and then nest a listener within Ext.onReady() or something like that, but I'm not sure how to do it in Ext4...
According to the docs, Ext.Application() gets launched "after the page is ready", so I guess that is the same as good old Ext.onReady()? So maybe I could somehow alter this behavior to launch it after the page is ready AND my API is loaded?
Or can I use the Ext.loader in some way perhaps?