Hi,
I'm currently struggling to work out how to trigger the 'beforeSubmit' event once a Save button has been clicked on a CMP. I have looked through some other packages etc and can see no difference between my code and the working code.
My main question is - 'How does the object know which button is the one to attach the 'beforeSubmit' and 'success' events to'?
Here are the appropriate parts of the code:
product.js
Common.page.Home = function(config) {
config = config || {};
Ext.applyIf(config,{
formpanel: 'panel-product'
,buttons: [{
text: _('save')
,id: 'product-btn-save'
,process: 'update'
,method: 'remote'
},'-',{
text: 'Back'
,id: 'product-btn-back'
,handler: function() {
location.href = '?a='+MODx.request.a
}
,scope: this
}]
,components: [{
xtype: 'panel-product'
,renderTo: 'products-panel-home-div'
}]
});
Common.page.Home.superclass.constructor.call(this,config);
};
Ext.extend(Common.page.Home,MODx.Component);
Ext.reg('page-home',Common.page.Home);
product.panel.js
Common.panel.Product = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,items: [{
xtype: 'modx-tabs'
,items: [{
title: _('products')
,items: this.getFields(config)
}]
}]
,listeners: {
'success': {fn:this.success,scope:this}
,'setup': {fn:this.setup,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'postReady': {fn:this.postReady,scope:this}
}
}); // Ext.apply
Common.panel.Product.superclass.constructor.call(this,config);
};
Ext.extend(Common.panel.Product,MODx.FormPanel, {
postReady: function() {
console.log('postReady');
}
,success: function() {
console.log('Success');
}
,setup: function(o) {
console.log('Setup');
}
,beforeSubmit: function() {
console.log('beforeSubmit');
}
,getFields: function(config) {}
});
Ext.reg('panel-product',Common.panel.Product);
In this example, the 'setup' function does fire, but the 'postReady' function doesn't and when I click the 'Save' button the 'beforeSubmit' and 'success' events do not fire.
Any help would be greatly appreciated.