1

私は Sencha に非常に慣れていないので、これはおそらく初心者のエラーです :)

Sencha でページ ナビゲーションを実装しようとしています。次のシナリオは機能します。

ホーム画面とログイン画面を備えた Main.js があります。資格情報を入力すると、Home.js に転送されます。

ただし、ホームはログイン後にのみ表示できるため、メインからホームを削除したいと考えています。しかし、Main.js から xtype ホームを削除すると、もう見つかりません。理由がわかりません。

Main.js

config : {
    tabBarPosition : 'bottom',

    items : [{
        xtype : 'startview',
    }, {
        xtype : 'contactform'
    }, {
        xtype : 'loginform'
    }, {
        xtype : 'createaccountform'
    }, {
        xtype : 'homeview' REMOVING THIS MAKES THE HOME undefined in the controller
    }]
}

私のコントローラー

Ext.define("MyApp.controller.LoginController", {
extend : "Ext.app.Controller",

xtype : 'logincontroller',

requires : ['Ext.app.Router', 'MyApp.view.Home'],

config : {
    refs : {
        loginForm : "#loginFormPanel",
        home : 'homeview'
    },

    routes : {
        login : 'authenticateuser'
    },
    control : {
        'button[action=login]' : {
            tap : "authenticateUser"
        }
    },
    views : ['Login', 'Home']
},

authenticateUser : function(button) {

            **// WHEN REMOVING xtype: homeview from MAIN this getter returns undefined (??)**
    var activeView = this.getHome(); 

    this.getLoginForm().submit({
        url : 'php/process_login.php',
        method : 'POST',
        success : function(form, result) {

            alert('Success and moving to home ' + activeView);
            Ext.Viewport.setActiveItem(activeView);
        },
        failure : function(form, result) {

            alert('2');

            Ext.Msg.alert('Error', 'failure....' + result);
        }
    });
}
});

ホーム.js

Ext.define('MyApp.view.Home', {
extend : 'Ext.tab.Panel',
id : 'home',
xtype : 'homeview',
requires : ['Ext.TitleBar', 'Ext.Video'],
config : {
    title : 'Home',
    iconCls : 'home',
    tabBarPosition : 'bottom',

    items : [{
        xtype : 'searchview',
    }, {
        xtype : 'profileview'
    }, {
        xtype : 'messagesview'
    }, {
        xtype : 'sensesview'
    }]

}

});

app.js

views : ['Start', 'Main', 'Contact', 'Login', 'CreateAccount', 'Home', 'Messages', 'Profile', 'Search', 'Senses'],

controllers : ['LoginController'],

では、(メインから削除した後)コントローラーでホームへの参照を引き続き取得するにはどうすればよいですか??

助けてくれてありがとう、コーエン

4

1 に答える 1

1

HomeitemId代わりにを与えたいid

Ext.define('MyApp.view.Home', {
    extend : 'Ext.tab.Panel',
    itemId : 'home',
    xtype : 'homeview',
    ...
});

そして今、コントローラーで、次のように参照します。

...
config : {
refs : {
    loginForm : "#loginFormPanel",
    home : {
            autoCreate: true,
            selector: '#home',
            xtype: 'homeview'
        }
},
...
于 2013-02-26T13:57:45.403 に答える