PDA

View Full Version : Defining the api in the FormPanel in constructor and initComponent



mitchellsimoens
25 Feb 2011, 8:25 AM
When I first started this project of rewriting an application, I had a problem defining the APIs for the FormPanel for loading and submitting. It works when I define the APIs in the constructor but not the initComponent. Not sure if it's the way the dev before me setup things or if it is an actual bug.

This will load and submit just fine:

TestForm = Ext.extend(Ext.form.FormPanel, {
...
constructor: function(config) {
config = config || {};
Ext.applyIf(config, {
api: {
load: Action.method,
submit: Action.method
}
});
TestForm.superclass.constructor.call(this, config);
},
...
});

this will not load or submit to the correct url. It will go to the base url and then append 'undefined'

TestForm = Ext.extend(Ext.form.FormPanel, {
...
initComponent: function() {
Ext.applyIf(this, {
api: {
load: Action.method,
submit: Action.method
}
});
TestForm.superclass.initComponent.call(this);
},
...
});

Is this the correct way to assign the API, only in the constructor? Not a big deal if it is.