Ну примерно так
MyForm = Ext.extend(Ext.form.FormPanel, {
border : false,
frame : true,
labelWidth : 120,
url : 'url',
,initComponent : function() {
var config = {
defaultType : 'textfield',
defaults : {
anchor : '-24',
msgTarget : 'side'
},
monitorValid : true,
autoScroll : true,
items : [ ],
buttons : [ {
text : 'Сохранить',
iconCls : 'icon-tick',
formBind : true,
scope : this,
handler : this.submit
}, {
text : 'Отмена',
iconCls : 'icon-cross',
scope : this,
handler : function() {
this.fireEvent('chancel');
}
} ]
};
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
MyForm.superclass.initComponent.apply(this, arguments);
// add custom events
this.addEvents('saved');
}
,onRender : function() {
// call parent
MyForm.superclass.onRender.apply(this, arguments);
this.getForm().waitMsgTarget = this.getEl();
} // eo onRender
,submit : function() {
this.getForm().submit( {
url : this.url,
scope : this,
success : this.onSuccess,
failure : this.onFailure,
waitMsg : 'Сохранение данных...'
});
} // eo submit
,onSuccess : function(form, action) {
var responseObj = Ext.decode(action.response.responseText);
// send the new record id
this.fireEvent('saved', responseObj);
}
,onFailure : function(form, action) {
var responseObj = Ext.decode(action.response.responseText);
this.showError(action.result.error || responseObj.errormsg);
}
,showError : function(msg, title) {
title = title || 'Error';
Ext.Msg.show( {
title : title,
msg : msg,
modal : true,
icon : Ext.Msg.ERROR,
buttons : Ext.Msg.OK
});
}
}); // eo extend
// register xtype
Ext.reg('MyForm', MyForm);
И далее где угодно
MyForm.on('saved', function(responseObj) {
// Что делаем
});