Sencha touch 2,Uncaught TypeError: undefined is not a function

491 views Asked by At

I am very new to Sencha touch, and I was wondering how i can send post data. I am facing two issues now. 1) I keep getting Uncaught TypeError: undefined is not a function when I attempt to get form data, and 2) how do I post the data to a remote restful api in codeigniter.

My controller now that gives me the error

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

the view

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

});

Working further on this code, it is suppose to post the data to a remote server running with codeigniter rest api. Wish some kind soul can show me the way from here.

1

There are 1 answers

0
Mark Seah On

Not getting wink to solve this. Found the issue. I am using Ext.panel and i have set the id at the fieldset. After some researching online, fieldset does not come with .getValues(); It is from Ext.form.Panel.

So the final code should be, for the view

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

});