PDA

View Full Version : How do I access the outer class defintion instance



kisundar
15 Nov 2012, 11:49 AM
Ext.define('BuildStatus.view.Login',{
extend: 'Ext.form.Panel',
title: 'Login Page',
url: 'login.jsp',
defaultType: 'textfield',
bodyStyle:'padding:5px 5px 0',
buttonAlign: 'left',
items: [
{
fieldLabel: 'Name',
name: 'name',
allowBlank:false
},
{
fieldLabel: 'Password',
name: 'password',
allowBlank:false
}
],
frame:true,
buttons: [{
text: 'Login',
formBind: true,
//Function that fires when the user clicks the button
handler: function()
{
console.log("button clicked");
getForm().submit(
{
method: 'POST',
waitTitle: 'Connecting',
waitMsg: 'Sending data...',

success: function()
{
console.log("Login successful.");
},
failure: function(form, action)
{
console.log("Login failed.");
getForm().reset();
}
});

}
}]
})




Now the question I have is when i run this, i get an error saying that getForm() is undefined. How do I access the form instance when the button is clicked. Kindly advice.

droessner
15 Nov 2012, 2:05 PM
Inside the button handler you can use this.up('form') to get the form instance.