1

我试图在我的 sencha touch 应用程序中达到我的表单的值,该应用程序是由拼凑的教程构建的。我希望它是一个 MVC 模式应用程序,所以我使用

app.views.Login = Ext.extend(Ext.form.FormPanel, formBase = {...})

并在那里初始化它

 app.views.Login.superclass.initComponent.apply(this, arguments);

以及像 sencha touch phonegap MVC 教程(链接)中的视口,我在其中应用登录页面,例如

Ext.apply(app.views, {loginPage: new app.views.Login()});

在我的应用程序中,当我单击表单的发送按钮时,我尝试捕捉表单的字段

handler: function() {
    console.log('username ', app.views.Login.getValues().username);
    Ext.Ajax.request({
        url: app.views.Login.url,
        method: 'POST',
        params: {username: form.getValues().username, password : form.getValues().password},
        failure : function(response){
                    console.log('Login Error! ' + response.responseText);
                },
        success: function(response, opts) {
                    console.log('Login success! response: ' + response.responseText);
                  }
    });
}

但我总是得到一个错误,上面写着

未捕获的类型错误:无法调用未定义的方法“getValues”

当我使用

console.log('username ', this.getValues().username);

那么我怎样才能达到表单值呢?

谢谢!!!

4

1 回答 1

1

查看Sencha Touch API Documentation,我没有看到方法getForm(),但getValues()应该可以从您的按钮handler功能中访问:

app.views.loginPage.getValues();
于 2011-04-14T17:31:26.897 回答