views:

176

answers:

1

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 conn = 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?

+1  A: 

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'
};
bmoeskau
Thanks for the help. I made a function called just before the Ajax requests Ext.Ajax.on('beforerequest', beforerequest, this); From this I was able to apply headers, modify the URL etc. My custom connection class is no more!
geographika