Using Ext.data.Connection for a Form Load Action
I have created a custom extension of Ext.data.Connection that adds in a couple of headers for all my Ajax requests.
I'd like to use the same Connection class to submit a form similar to below, but it seems the http://www.sencha.com/deploy/dev/docs/?class=Ext.form.Action has its own configuration.
var 开发者_如何学Goconn = new MyCustom.Request({
method: 'GET',
endpoint: this.routeGetURI + this.routeid,
failure: function(form, action){
Ext.Msg.alert("Load failed", action.result);
},
success: this.fillFormValues
});
this.getForm().load(conn);
Is there simple way to force the form to use my connection object?
Instead of subclassing Connection, have you tried simply adding your default headers to the global Ext.Ajax singleton? The form Action classes use that singleton under the covers, so you should be able to simply do something like this:
Ext.Ajax.defaultHeaders = {
'my-header': 'foo',
'another': 'bar'
};
精彩评论