0

我對sencha touch很新,我想知道如何發送post數據。我現在面臨兩個問題。 1)我一直在獲取Uncaught TypeError:undefined不是函數,當我嘗試獲取表單數據時,以及2)如何將數據發佈到codeigniter中的遠程restful api。Sencha touch 2,Uncaught TypeError:undefined不是函數

我控制器現在給我的錯誤

Ext.define('tileconmob.controller.Main',{ 
    extend:'Ext.app.Controller', 
    views:['Home','Address','Workers','Firstpage'], 
    models:['People','Worker'], 
    config:{ 
     refs:{ 
      loginForm:'#loginform' 
     }, 
     control:{ 
      'button[action=loginUser]':{ 
      tap:'LoginUser' 
     } 
     } 
    }, 
      LoginUser:function(button,event){ 
       console.log("event in controller was fired"); 
       //console.log(this.referenceList); 
       var values=this.getloginForm().getValues(); 
       console.log(values);} 
}); 

認爲

Ext.define('tileconmob.view.Home', { 
    extend: 'Ext.Panel', 
    xtype: 'profilepanel', 
    config: { 
     title: 'About us', 
     iconCls: 'home', 
     styleHtmlContent: true, 
     scrollable: true, 
     items: [{docked: 'top', 
       xtype: 'titlebar', 
       title: 'Login'}, 

      { 
       xtype: 'fieldset', 
       title: 'About You', 
       id:'loginform', 
       items: [{ 
         xtype: 'textfield', 
         name: 'name', 
         label: 'Full Name' 
        }, 
        { 
         xtype: 'textfield', 
         name: 'password', 
         label: 'Password' 
        }, 
        { 
         xtype:'button', 
         ui:'submit', 
         text:'Login', 
         action:'loginUser' 
        } 
       ] 
      }] 
    } 

}); 

這個代碼進一步合作,這是假設把數據上傳到遠程服務器笨REST API運行。希望某種靈魂可以讓我看到從這裏出發的路。

回答

0

沒有得到眨眼解決這個問題。發現問題。我正在使用Ext.panel,我已經在fieldset中設置了id。經過一些在線研究,fieldset不會帶有.getValues();它來自Ext.form.Panel。

所以最終的代碼應該是,認爲

Ext.define('tileconmob.view.Home', { 
    extend: 'Ext.form.Panel', 
    xtype: 'profilepanel', 
id:'loginform', 
    config: { 
     title: 'About us', 
     iconCls: 'home', 
     styleHtmlContent: true, 
     scrollable: true, 
     items: [{docked: 'top', 
       xtype: 'titlebar', 
       title: 'Login'}, 

      { 
       xtype: 'fieldset', 
       title: 'About You', 
       items: [{ 
         xtype: 'textfield', 
         name: 'name', 
         label: 'Full Name' 
        }, 
        { 
         xtype: 'textfield', 
         name: 'password', 
         label: 'Password' 
        }, 
        { 
         xtype:'button', 
         ui:'submit', 
         text:'Login', 
         action:'loginUser' 
        } 
       ] 
      }] 
    } 

}); 
相關問題