答案:先执行init()方法,再执行onLaunch()方法。
引自:
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.app.Controller-method-onLaunch
A template method like init, but called after the viewport is created. This is called after the launch method of Application is executed.
Available since: 4.0.0
This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.
Parameters
- application : Ext.app.Application
例子如下:
Ext.define('cdkj.controller.correct.CorrectionEndController', {
extend : 'Ext.app.Controller',
views : [
'correct.end.CorrectionEndListView',
'correct.end.CorrectionEndContainer',
'common.DeptTreePanel',
'common.ListToolbar',
'correct.end.CorrectEndButton',
'correct.end.CorrectionEndSearchView',
// 'sys.BaseSearchPanel',
// 'common.DictionaryCombo'
'correct.end.CorrectEndSearchMoreWin',
'common.DictionaryCombo',
'correct.end.CorrectEndAddLayer',
'correct.end.CorrectEndTabContainer'
],
stores : [ 'correct.CorrectionEndStore',
'correct.ArchiveStore', 'common.DeptTreeStore'
,'common.DictionaryComboStore'
],
models : [ 'correct.CorrectionEndModel',
'correct.ArchiveModel', 'common.DeptModel'
,'common.ComboxModel'
],
//便于获取组件,名字为与别名相同,下面可以直接用getXXX()方法,类似Ext.ComponentQuery.query()功能。
refs :[{ref:'correctCorrectionEndContainer',selector:'correctCorrectionEndContainer'},
{ref:'correctCorrectionEndListView',selector:'correctCorrectionEndContainer correctCorrectionEndListView'},
{ref:'deptTreePanel',selector:'correctCorrectionEndContainer deptTreePanel'},
{ref:'listToolbar', selector:'listToolbar'},
//
// {ref:'sysBaseSearchPanel', selector:'sysBaseSearchPanel'}
{ref:'correctionEndSearchView', selector:'correctionEndSearchView'},
// {ref:'correctEndSearchMoreWin', selector:'correctEndSearchMoreWin'},
{ref:'correctEndSearchMoreWin',
selector:'correctCorrectionEndListView correctEndSearchMoreWin#message-moresearch-view',
xtype : 'correctEndSearchMoreWin',
autoCreate : true
}
],
init : function() {
alert(111);
this.control({
'correctCorrectionEndContainer deptTreePanel' : {// 绑定部门树的单击事件
itemclick : this.loadCorrectionEndTree
},
'correctCorrectionEndListView button[action=add]' : {// 绑定新增按钮
click : this.addCorrectionEnd
},
'correctCorrectionEndListView button[action=search]' : {// 绑定查询按钮
click : this.searchCorrectionEnd
},
'correctCorrectionEndListView button[action=export]' : {// 绑定导出按钮
click : this.exportCorrectionEnd
},
'correctCorrectionEndListView button[action=more]' : {// 绑定更多按钮
click : this.showMoreAction
},
'correctCorrectionEndListView button[action=search-more]' : {// 绑定更多搜索按钮
click : this.searchMoreCorrectionEnd
}
});
},
onLaunch:function(container){
alert(222);
var panel = Ext.widget('correctCorrectionEndContainer');
container.add(panel);
// var correctionEndStore = this.getCorrectCorrectionEndListView().store;
// correctionEndStore.reload();
}
}
///
以上例子先弹窗:
alert(111);
再弹窗:
alert(222);