PDA

View Full Version : Problem with form.on



dizor
17 Mar 2009, 10:55 AM
Ext.getCmp('mainForm').form.on('actioncomplete', function(form, action){
console.log(action.type);
if(action.type=='load'){
Ext.getCmp('invoiceselementsgrid3').store.load({params:{'id':id}});
}
}, this);

Ext.getCmp('mainForm').getForm().load({url:'form/get_customers',params:{id:id}});


I have problem with this code - on first run everything is ok, on second actioncomplete runs two times, on third - three times. What is wrong?

tryanDLS
17 Mar 2009, 10:59 AM
Suggest you set some breakpoints and see how many times you're executing that statement as you go thru - my guess would be that you're adding the listener each time thru.

dizor
17 Mar 2009, 11:05 AM
openDetail: function(id){
Ext.getCmp("mainForm").getForm().reset();
Ext.getCmp('mainForm').form.on('actioncomplete', function(form, action){
console.log(action.type);
if(action.type=='load'){
//Ext.getCmp('invoiceselementsgrid3').store.load({params:{'id':id}});
}
}, this);
console.log('test');
Ext.getCmp('mainForm').getForm().load({url:'form/get_customers',params:{id:id}});
},


Problem is with line:


Ext.getCmp('mainForm').getForm().load({url:'form/get_customers',params:{id:id}});


When i run openDetail "console.log('test')" is always ok - "console.log(action.type)" is first - one, second - two etc.
I run openDetail with:



listeners:{
"rowclick":{
fn:function(grid, rowIndex, e){
var r = grid.getStore().getAt(rowIndex);
this.openDetail(r.data['id']);
},scope:this
}
}


Edit: i checked this problem - run openDetail on button - the same problem. I use desktop.