PDA

View Full Version : Can I add my handler like this to Designer code?



ExtKD
23 Mar 2010, 7:00 AM
n/a

mschwartz
24 Mar 2010, 5:28 AM
First post looks better than the 2nd.

I don't see why you want to avoid calling getCmp() - it's fast.

mschwartz
24 Mar 2010, 6:01 AM
My code tends to look like this:



LoginWindowUI = Ext.extend(Ext.Window, {
initComponent: function() {
var me = this;
var myId = Ext.id();
var config = {
layout: 'form',
id: myId,
items: [
...
]
};
Ext.apply(this, ext.apply(this.initialConfig, config));
this.bbar = new Ext.Toolbar({
items: [
{
text: 'Login',
handler: function() {
Ext.getCmp(myId).getForm().submit({
...
});
}
}
]
});
LoginWindowUI.superclass.initComponent.apply(this, arguments);
});

mschwartz
24 Mar 2010, 6:03 AM
Though I rarely use form.submit() - only if there's a file upload.

I'd do Ext.getCmp() on each of the fields and validate them and then use Ext.Ajax.request() to post to the server.

aconran
26 Mar 2010, 1:04 AM
I would suggest setting itemId's on the components that are contained within your top level Container.

You can then use getComponent which is scoped by itemId before id. This will make it so that your LoginWindow class can be re-used and does not run into id collisions.