Javascript Sencha架构师从其他函数调用函数
我有一个FormPanel,如下所示,它定义了几个函数。 我需要从另一个函数调用一个函数,但我得到了一个错误 我正在调用的函数未定义。 如果我从onmybuttonap函数调用ShowInspections,它就会工作 如果我从LoginOk函数调用ShowInspections,它将不起作用 我很困惑,我相信这是一个范围问题,但我真的需要这么新的信息 一些帮助Javascript Sencha架构师从其他函数调用函数,javascript,extjs,sencha-architect,Javascript,Extjs,Sencha Architect,我有一个FormPanel,如下所示,它定义了几个函数。 我需要从另一个函数调用一个函数,但我得到了一个错误 我正在调用的函数未定义。 如果我从onmybuttonap函数调用ShowInspections,它就会工作 如果我从LoginOk函数调用ShowInspections,它将不起作用 我很困惑,我相信这是一个范围问题,但我真的需要这么新的信息 一些帮助 Ext.define('MyApp.view.LoginPanel', { extend: 'Ext.form.Panel', ali
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');
}
}) 当前代码中有一些输入错误
this.ShowInspection);
应读为
this.ShowInspections();
这不是你的问题吗?你错过了所有需要更改的地方,例如this.LoginOk、this.LoginFail等。ShowInspections我疯了吗,或者示例代码甚至没有一个名为GetInspections的函数?