1. 四种调用controller中的函数:
- html link:
<a href="#Home/about"class="menu-item">About</a>
格式: <a href="#route">some link</a> - Ext.redirect('Home/index'), Ext.redirect是Ext.Dispatcher.redirect的简写,会自动添加这个Home/index 到历史栈,但是无法添加动画param,来显示新页面时的动画,但会自动添加historyUrl
- Ext.dispatch 可以传递param,这里用到4个params:
controller:指定哪个controller,相似scope
action:指定controller中哪个action将被调用
historyUrl: 这里必须显示著名将要调用的 :controller/:action,如果不添加这个param,当从其他页面B返回到这个页面A,游览器地址仍旧是地址B,而不是A,所以从A页面调用B页面将无法工作,因为游览器以为已经到了页面B。剩下的custom property "animation"来传递一个动画变量,animation:{type: 'slide', reverse:true}: reverse表示当加载另一个页面时用相反的方向,原来是left,现在是right - Ext.ControllerManag.get('ControllerId')可以直接得到一个对应的Controller,通过这个来直接调用它的方法.例如:
Ext.ControllerManager.get('Search').index();
2. 通过this.render创建一个指定类型的view, 然后this.application.viewport.setActiveItem来加载这个view:
index: function(options){
if(!this.indexView){
this.indexView = this.render({
xtype: 'HomeIndex',//建立一个自定义的view
});
}
var backBtn = this.application.viewport.query('#backBtn')[0];
backBtn.hide();
this.application.viewport.setActiveItem(this.indexView, options.animation);//如果没有给出animation也没关系
},