PDA

View Full Version : [FIXED] Ext.form.Panel.submit.exception is never called



aatiis
4 Nov 2011, 4:47 AM
REQUIRED INFORMATION


Ext version tested:

Sencha Touch 2.0PR1
Browser versions tested against:

Chromium 16.0.912.15 (Developer Build 0 Linux)
DOCTYPE tested against:

HTML5 (<!doctype html>)
Description:

Ext.form.Panel.submit({exception: function(){...}}) is never called
Steps to reproduce the problem:

Create a form & send a response from the server containing {success: false}
The result that was expected:

Failure callback
The result that occurs instead:

Infinite loading screen
Test Case:




Ext.form.Panel.create({
items: [{
name: 'example',
xtype: 'textfield'
}]
}).submit({
success: function () {
// This works fine.
console.info('Everything went fine!');
},
exception: function () {
// This is never called!
console.error('Everything went fine!');
},
failure: function () {
// This works as well.
console.error('Network error or server error...')
}

})





HELPFUL INFORMATION

Possible fix:

src/form/Panel.js, lines 413-428



413 if (success) {
414 response = Ext.decode(responseText);
415 success = !!response.success;
416 if (success) {
417 if (Ext.isFunction(options.success)) {
418 options.success.call(options.scope || me, me, response, responseText);
419 }
420 me.fireEvent('submit', me, response);
421 }
422 }
423 else {
424 if (Ext.isFunction(options.failure)) {
425 options.failure.call(options.scope || me, me, response, responseText);
426 }
427 me.fireEvent('exception', me, response);
428 }



... should be ...




413 if (success) {
414 response = Ext.decode(responseText);
415 success = !!response.success;
416 if (success) {
417 if (Ext.isFunction(options.success)) {
418 options.success.call(options.scope || me, me, response, responseText);
419 }
420 me.fireEvent('submit', me, response);
421 }
422 else {
423 me.fireEvent('exception', me, response);
424 if (Ext.isFunction(options.failure)) {
425 options.failure.call(options.scope || me, me, response, responseText);
426 }
427 }
428 else {
429 if (Ext.isFunction(options.failure)) {
430 options.failure.call(options.scope || me, me, response, responseText);
431 }
432 }



Operating System:

Gentoo Linux ~amd64

mitchellsimoens
4 Nov 2011, 7:25 AM
Thank you for the report.

rdougan
7 Nov 2011, 1:25 PM
Fixed, thanks.

FYI, there is no exception callback in the options config, like your example has. There is an exception event, though.

aatiis
7 Nov 2011, 3:02 PM
Fixed, thanks.

FYI, there is no exception callback in the options config, like your example has. There is an exception event, though.

Oh, I didn't notice that. Thanks for the fix though!