depuis que je suis assez nouveau pour sencha toucher 2.0 je me demandais:
Comment puis-je créer un TabBarView avec un contrôleur pour chaque onglet?TabBarView avec plusieurs contrôleurs (meilleures pratiques)
Mon idée:
Créer le contrôleur onTabChange. Mais il doit y avoir une manière plus élégante?
Ma première approche:
Ext.define('app.controller.MainController', {
extend: 'Ext.app.Controller',
views: [
'TabBar',
'About'
],
ref: [
],
requires: [
'app.controller.About'
],
init: function() {
// Create tabbar and listen for events
this.tabBarView = this.getTabBarView().create();
this.tabBarView.addListener('activeitemchange', this.onActiveitemchange, this);
// Add views to tabbar
var aboutView = this.getAboutView().create();
this.tabBarView.add(aboutView);
// TODO: Add more views
// Crate application listeners
this.application.addListener('changeTab', this.changeTab, this);
},
/**
* Change tab (fired from views inside tabbar)
*/
changeTab : function() {
this.tabBarView.setActiveItem(0);
},
/**
* Listen for tabchange an map controller to view
*/
onActiveitemchange : function(container, newView, oldView, e) {
console.info("tabchange");
// Create appropiate controller
switch (newView.alias[0]) {
case 'aboutView':
var aboutController = this.application.getController('About');
break;
// TODO: Add more breakpoints
default:
console.warn("No controller mapped to: "+newView.alias);
};
// TODO: Remove old controller
}
});
Pourriez-vous s'il vous plaît expliquer plus en détail. Je n'ai pas compris. – fabian
Cela ne résout pas ce qui a été demandé. J'ai la même question que @fabian. –