煎茶架构师 从其他函数调用函数

Sencha Architect Calling function from other function

本文关键字:其他 函数调用 函数      更新时间:2023-09-26

我有一个定义了几个函数的FormPanel(见下文)。我需要从另一个函数调用一个函数,但我得到错误我正在调用的函数是未定义的。如果我从OnMyButtonTap功能调用ShowInspections,它可以工作如果我从 LoginOk 函数调用 ShowInspections,它不起作用我不知所措,我相信这是一个范围问题,但如此新,我真的需要煎茶一些帮助。

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(); 

这不是你的问题吗?

你错过了()到处,你只需要改变这样。LoginOk(),this。LoginFail() 等等等。显示检查()