2012-05-03 41 views
0

我有一個FormPanel(見下文),它定義了幾個函數。 我需要從另一個函數調用一個函數,但我得到的錯誤,我打電話的函數是不確定的 。 如果我把從該ShowInspections OnMyButtonTap發揮它的工作原理 如果我把從LoginOk功能ShowInspections它不工作 我很茫然,我相信這是一個範圍的問題,但這麼新的IT煎茶我真的需要 一些幫幫我。Sencha Architect從其他函數調用函數

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

});

+0

我瘋了,還是做示例代碼甚至沒有設有函數名爲GetInspections? – WCWedin

回答

0

當前代碼中有一些錯字。

this.ShowInspection); 

應爲

this.ShowInspections(); 

那不是你的問題嗎?

0

你錯過了()無處不在,你只需要改變爲this.LoginOk(),this.LoginFail()等,並this.ShowInspections()

相關問題