我有一个定义了多个函数的 FormPanel(见下文)。我需要从另一个函数调用一个函数,但我得到错误,我正在调用的函数未定义。如果我从 OnMyButtonTap 函数调用 ShowInspections 它可以工作如果我从 LoginOk 函数调用 ShowInspections 它不起作用我很茫然我相信这是一个范围问题,但是它是如此新 Sencha 我真的需要一些帮助。
Ext.define('MyApp.view.LoginPanel', {
extend: 'Ext.form.Panel',
alias: 'widget.Login',
config: {
items: [
{
xtype: 'fieldset',
height: 226,
width: 440,
title: 'Enter Login Information',
items: [
{
xtype: 'textfield',
id: 'userid',
label: 'User ID',
labelWidth: '40%',
required: true
},
{
xtype: 'textfield',
id: 'pswd',
label: 'Password',
labelWidth: '40%',
required: true
}
]
},
{
xtype: 'button',
height: 86,
itemId: 'mybutton',
text: 'Login'
}
],
listeners: [
{
fn: 'onMybuttonTap',
event: 'tap',
delegate: '#mybutton'
}
]
},
onMybuttonTap: function(button, e, options) {
doLogin(Ext.getCmp('userid').getValue(),Ext.getCmp('pswd').getValue(),this.LoginOk,this.LoginFail,this.LoginError);
},
LoginOk: function() {
//
// this function is called from doLogin and it works
//
//GetInspections('01/01/2011','12/31/2012','','',this.ShowInspections,this.LoadDataFail,this.LoadDataError);
// the function GetInspections does work, but does not call the "ShowInspections" function
this.ShowInspection); // directly calling this function does NOT work either
},
LoginFail: function() {
Ext.Msg.alert('Invalid User ID and/or Password.');
},
LoginError: function() {
Ext.Msg.alert('Login Error!');
},
LoadDataFail: function() {
Ext.Msg.alert('No Inspections found.');
},
LoadDataError: function() {
Ext.Msg.alert('Error Loading Inspections.');
},
ShowInspections: function() {
Ext.Msg.alert('got inspections');
}
});