0

我对 Sencha touch 很陌生,我想知道如何发送帖子数据。我现在面临两个问题。1)当我尝试获取表单数据时,我不断收到 Uncaught TypeError: undefined is not a function,以及 2)如何将数据发布到 codeigniter 中的远程 restful api。

我的控制器现在给了我错误

    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'
                    }
                ]
            }]
    }

});

进一步处理此代码,假设将数据发布到使用 codeigniter rest api 运行的远程服务器。希望有好心人能给我指路。

4

1 回答 1

0

没有眨眼来解决这个问题。发现问题。我正在使用 Ext.panel,并且我在字段集中设置了 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'
                    }
                ]
            }]
    }

});
于 2014-11-24T23:20:54.557 回答