1

Sencha Touch アプリケーションを作成していますが、ログイン後に別のビューをリダイレクトまたは変更するのに苦労しています。ログイン後、ホームページに移動する必要があります。しかし、ログインコントローラーのauthenticateUser()の以下のコードは機能していません

Ext.Viewport.push(homePanel) 、 Ext.Viewport.setActiveItem(homePanel) も試しました。しかし、何も機能しません。

ログインビュー

Ext.define("Mobile.view.LoginView", {
extend: "Ext.form.FormPanel",
alias: "widget.mylogin",
id: 'loginFormPanel',

config: {


    name: 'loginform',
    frame: true,
    url: 'login/Authenticate',
    title: 'Login',
    items: [

      {
          xtype: 'fieldset',
          itemId: 'LoginFieldset',
          margin: '10 auto 0 auto ',
          title: '',
          items: [

                {
                    //User Name field def
                },

                {
                    //Pwd Field Def
                }
            ]
      },
        {
            xtype: 'button',
            id: 'loginButton',           
            text: 'Login',
            action: 'login'
        }

    ]
}

});

ログイン コントローラ

Ext.define("Mobile.controller.LoginController", {
extend: "Ext.app.Controller",
views: ['LoginView', 'HomeView'],
models: ['UserModel'],
config: {
    refs: {
        loginForm: "#loginFormPanel"
    },
    control: {
        'button[action=login]': {
            tap: "authenticateUser"
        }
    }
},

authenticateUser: function (button) {
            loginForm.submit({
            method: 'POST',
            success: function (form, result) {
            //THIS IS NOT WORKING
                Ext.Viewport.add(Ext.create('Mobile.view.HomeView'));

            },
            failure: function (form, result) {                   
                console.log('Error');
                Ext.Msg.alert('Check the logic for login and redirect');
            }
        });
       }           
});

ホーム ビュー

Ext.define('Mobile.view.HomeView', {
extend: 'Ext.Container',
id: 'homescreen',
alias: "widget.homepanel",
 config: {
    layout: {
        type: 'card',
        animation: {
            type: 'flip'
        }
    },
    items: [
        {
            xtype: 'toolbar',
            docked: 'bottom',
            id: 'Toolbar',
            title: 'My App',
            items: [
                {
                    id: 'settingsBtn',
                    xtype: 'button',
                    iconCls: 'settings',
                    ui: 'plain',
                    iconMask: true
                }
            ]
        },
        {
            xclass: 'Mobile.view.ActionListView'
        }
    ]
},
});

App.JS

Ext.application({
name: "Mobile",
controllers: ["LoginController", "HomeController"],
views: ['LoginView', 'HomeView', 'ActionListView'],
models: ['UserModel', 'OrganizationModel', 'ActionModel'],
stores: ['OrganizationStore', 'ActionStore'],
launch: function () {

    var loginPanel = Ext.create('Ext.Panel', {
        layout: 'fit',
        items: [
            {
                xtype: 'mylogin'
            }
        ]
    });
    Ext.Viewport.add(loginPanel);
}

});

誰でも何か考えがありますか?参照済み sencha touch 2.0 でログイン後、別のビューを読み込みます。しかし、答えはありません。助けてください

4

3 に答える 3

6

You need create a ref for your HomeView:

    refs: {
        HomeView: {
            autoCreate: true,
            selector: 'HomeView',
            xtype: 'HomeView'
        },
    }

And set this view active:

    Ext.Viewport.setActiveItem(this.getHomeView());
于 2012-10-09T23:18:58.490 に答える
1

Sencha Touch 2 を使用している場合は、Route を使用して別のページにリダイレクトする必要があります。したがって、次のようになります。

this.redirectTo('home');

次に、ルート「ホーム」を持つコントローラーを作成します

ルートの詳細については、こちらをご覧ください。http://docs.sencha.com/touch/2-0/#!/guide/controllers-section-4

于 2012-10-11T10:49:37.960 に答える
0

Try this. may be this work.

authenticateUser: function (button) {
        loginForm.submit({
        method: 'POST',
        success: function (form, result) {

         var home= Ext.create('Mobile.view.HomeView');
         Ext.getCmp('loginFormPanel').destroy();
         Ext.Viewport.add(paneltab);

        }
于 2012-10-09T13:41:46.130 に答える