0

I have a FormPanel (See below) that has several functions defined. I need to call one function from another function, but I get error that the function I am calling is undefined. If I call the ShowInspections from the OnMyButtonTap function it works If I call the ShowInspections from the LoginOk function it DOES NOT work I am at a loss I believe it is a scope issue, but so new it Sencha I really need some help.

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');
}

});

sha
  • 17,824
  • 5
  • 63
  • 98

2 Answers2

0

There is some typo in the current code.

this.ShowInspection); 

should read as

this.ShowInspections(); 

Isn't that your problem?

Zoltan Magyar
  • 874
  • 1
  • 6
  • 19
0

You have missed () everywhere you just need to change as this.LoginOk(), this.LoginFail() etc and this.ShowInspections()

Ram G Athreya
  • 4,892
  • 6
  • 25
  • 57