PDA

View Full Version : Success Handler Scope on Form POST



brookd
24 Nov 2007, 9:30 AM
I must be missing something here. I am trying to set the scope on the success handler of a form post. I have tried numerous ways, and I can get inline success/failure functions to work, but I can not get a reference the parent class and I can not seem to get the scope.

I am trying:


buttons: [{
text: 'Login',

handler: function() {
if (loginForm.getForm().isValid()){
loginForm.getForm().submit({
url:'/extPublicAdapter/extAdapter.lf?request=login',
success: this.loginResult,
failure: this.loginFailure,
scope: this,
});
}
}
}]

I don't get any error, but also my log() in loginResult() and/or loginFailure() never gets run. I am using firebug and see the response from the server but nothing happens. What am I missing?

hendricd
24 Nov 2007, 9:33 AM
The default scope for a button handler is the button. You can specifiy an alternate scope:


buttons: [{
text: 'Login',
scope:this, //or explicitly: MyApp
handler: function() {
if (loginForm.getForm().isValid()){
loginForm.getForm().submit({
url:'/extPublicAdapter/extAdapter.lf?request=login',
success: this.loginResult,
failure: this.loginFailure,
scope: this,
});
}
}
}]

brookd
24 Nov 2007, 11:26 AM
Perfect, thank you!