私は 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'],
では、(メインから削除した後)コントローラーでホームへの参照を引き続き取得するにはどうすればよいですか??
助けてくれてありがとう、コーエン