未捕获的类型错误:对象[对象对象]在sencha touch中没有方法“提交”错误2.1

问题描述:

我在提交此表单时遇到问题。当我点击提交按钮时,它显示 Uncaught TypeError:Object [object Object]没有方法'submit'错误。未捕获的类型错误:对象[对象对象]在sencha touch中没有方法“提交”错误2.1

submitcontactform :function() 
    { 

     var form= this.getLoginform(); 
     form.submit({ 
      url:'contact.php' 
     }); 
    } 

在此先感谢

编辑:

我login.js

Ext.define('sencha.view.Login',{ 
      extend:'Ext.Panel', 
      xtype:'LoginPanel', 
      id:'loginform', 
      config:{ 
       title:'LoginForm', 
       items: [ 
         { 
          xtype: 'emailfield', 
          name : 'email', 
          label: 'Email' 

         }, 
         { 
          xtype: 'passwordfield', 
          name : 'password', 
          label: 'Password' 

         }, 
         { 
          xtype:'button', 
          text:'Submit', 
          ui:'confirm', 
          action:'submitForm' 

         } 
         ] 
      } 


}); 

我控制器

Ext.define('sencha.controller.main',{ 
    extend:'Ext.app.Controller', 

    views :['MainView','Login'], 
    config: 
    { 
     refs: 

     { 
    loginform:'#loginform' 
      //selector:'#buttonform' 
     } 

    }, 
    init: function(){ 

     this.control({ 
      'button[action=submitForm]':{ 
      tap:'submitcontactform' 
     } 

     }); 

    }, 
    submitcontactform :function(btn) 
    { 
     //console.log('im a function'); 
     //var form= this.getLoginform(); 
     var form=btn.up('formpanel'); 
     form.submit({ 
      url:'contact.php' 
     }); 
    } 
}); 

和我app.js

Ext.application({ 
    name:'sencha', 
    controllers : ['main'], 

    views :['MainView','Login',''], 
    //stores: ['presidentstore'], 
    //models: ['presidentmodel'], 
    launch:function(){ 
      Ext.create('sencha.view.MainView'); 
       //Ext.Viewport.add({ 
       // xclass:'sencha.view.presidentlist' 
       //}); 

    } 

}); 
+0

你是如何得到这个形式?你在控制器中正确引用它吗?这可能会有所帮助:http://www.sencha.com/forum/showthread.php?185671-Uncaught-TypeError-Object-object-Object-has-no-method-getContactForm/page2 – cclerville 2013-03-21 13:52:13

+0

@cclerville谢谢。我看到了链接,但它并没有帮助我解决问题。现在它的显示如下Uncaught TypeError:无法调用未定义.any创意的方法'submit'... – ram 2013-03-22 06:00:11

+0

您能向我们展示您的控制器配置和登录窗体类,以便我们确定您使用的是正确的选择器? – ThinkFloyd 2013-03-22 06:34:17

您的LoginPanel有问题。您的id应该在config之内。这就是说,我会建议使用itemId来代替。你应该LoginPanel这个样子:

Ext.define('sencha.view.Login',{ 
     extend:'Ext.Panel', 
     xtype:'LoginPanel', 
     config:{ 
      title:'LoginForm', 
      itemId: 'loginform', 
      items: [ 
        { 
         xtype: 'emailfield', 
         name : 'email', 
         label: 'Email' 
        }, 
        { 
         xtype: 'passwordfield', 
         name : 'password', 
         label: 'Password' 
        }, 
        { 
         xtype:'button', 
         text:'Submit', 
         ui:'confirm', 
         action:'submitForm' 
        } 
       ] 
     } 
}); 

最后,你的控制器应是这个样子:

... 
config:{ 
    refs:{ 
     loginform:{ 
      autoCreate: true, 
      selector:'#loginform', 
      xtype: 'LoginPanel' 
     } 
    }, 

    control : { 
     'button[action=submitForm]' : { 
      tap : "submitcontactform" 
     } 
    }, 
}, 

submitcontactform :function(btn) { 
    //console.log('im a function'); 
    var form= this.getLoginform(); 
    form.submit({ 
     url:'contact.php' 
    }); 
} 
...