【问题标题】:Sencha touch 2 changing views programaticallySencha touch 2 以编程方式更改视图
【发布时间】:2014-01-02 13:27:16
【问题描述】:

我是 Sencha Touch 的新手,我正在尝试开发一个包含 用户注册 视图和 用户登录 视图的应用程序。

主视图有一个登录按钮和一个注册按钮。

我想要完成的是更改视图以响应被点击的按钮。

以下是我正在使用的代码:

 Ext.define('MyApp.controller.RegisterForm', {
    extend: 'Ext.app.Controller',

    requires: ['Ext.data.JsonP'],

    config: {
        refs: {
            mainPage: 'mainpage',
            loginForm: 'loginform',
            registerForm: 'registerform'
        },
        control: {
            'button[action=UserNewAccount]': {
                tap: 'onNewAccount'
            },
        }
    },//config

    /**
     * respond when new account is requested
     */
     onNewAccount: function(event){

        /**
         * I have tried this ...
         */
        this.getLoginForm().add(this.getRegisterForm());
        this.getLoginForm().setActiveItem(this.getRegisterForm());

        /**
         * ... and this
         */
         this.getLoginForm().setActiveItem({
            xtype: 'registerform'
        });

        console.log('New account requested: ');
     }

});

onNewAccount 函数反应良好。 console.log 调用执行。问题是上面的代码。我已经尝试了这两种不同的方法,但没有成功。

谁能告诉我我做错了什么以及如何改变我的观点?

【问题讨论】:

    标签: sencha-touch-2


    【解决方案1】:

    注册表单似乎不是您的登录表单的子组件。您必须从父容器调用setActiveItem

    this.getMainPage().setActiveItem(this.getRegisterForm());

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-03
      相关资源
      最近更新 更多