PDA

View Full Version : Form submit & success



pbartels
29 Sep 2009, 11:48 PM
Hi all,

I'm not able to use the success return when submitting a form, this event is not triggered :((

I am using Ext Direct to post a form having:

api: {submit: Controller.SaveData}
in the config.

However I also defined a handler for a submit button which submits the form using form.submit().
In the submit config I defined a success function. As mentioned before this success function is not triggered.

Complete code:

var formActionButtons = [];
if(!isNew){
formActionButtons.push({
text: 'Delete',
handler: function(){
form.getForm().submit({params:{extTable:tableName,delete:"1"}});
}
})
}
formActionButtons.push({
text: 'Submit',
handler: function(){

form.getForm().submit({
params:{extTable:tableName},
success:function(a,b){
alert('q');
}
});
}
})

var form = new Ext.form.FormPanel({
buttons:formActionButtons,
title: tableName,
id : 'mainform',
border: false,
api: {submit: Controller.SaveData},
padding: 10,
paramOrder: ['uid'],
defaultType: 'textfield',
defaults: {anchor: '100%'},
items: this.GetItems(tableName)
});
return form;

Ciao!

Animal
29 Sep 2009, 11:53 PM
The failure handler?

pbartels
29 Sep 2009, 11:57 PM
Yeah, it's in the failure handler but the form is submitted successfull.
Why is the result in the failure and not in the success?

Animal
29 Sep 2009, 11:59 PM
Obviously it was not successful.

So, having written a failure handler, you'll be examining the http://www.extjs.com/deploy/ext-3.0.0/docs/?class=Ext.form.Action&member=failureType

What is the failure type?

pbartels
30 Sep 2009, 12:06 AM
There is no failureType only a type=directsubmit and result={}.
Even my firebug says there is a HTTP status 200 result.

Animal
30 Sep 2009, 1:03 AM
So what does your returned JSON look like?

pbartels
30 Sep 2009, 1:10 AM
This is the returned json:

"{"firstName":"Peter","lastName":"Bartels","age":""}"

Exactly the same I return from my server function.
The failure function does the same I expect from the success. Bug?

Animal
30 Sep 2009, 1:17 AM
http://www.extjs.com/deploy/ext-3.0.0/docs/?class=Ext.form.Action.Submit !

pbartels
30 Sep 2009, 1:29 AM
Ok that's it. I now return the @success property.
Thanks Animal