【问题标题】:Sencha Architect Calling function from other functionSencha Architect 从其他函数调用函数
【发布时间】:2012-05-03 16:04:21
【问题描述】:

我有一个定义了多个函数的 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');
}

});

【问题讨论】:

  • 我是不是疯了,或者示例代码甚至没有一个名为 GetInspections 的函数?

标签: javascript extjs sencha-architect


【解决方案1】:

当前代码中有一些错字。

this.ShowInspection); 

应该读作

this.ShowInspections(); 

这不是你的问题吗?

【讨论】:

    【解决方案2】:

    你在任何地方都错过了 (),你只需要更改为 this.LoginOk()、this.LoginFail() 等和 this.ShowInspections()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-26
      • 2023-03-26
      • 2013-07-20
      • 2013-01-12
      • 1970-01-01
      • 2019-09-24
      • 2016-05-27
      • 1970-01-01
      相关资源
      最近更新 更多