由於埃文說,Ext.onReady將僅針對負載第一次瀏覽HTML頁面。
如果您使用的是ExtJS 4,那麼從app.js加載腳本通常會落入MVC模式。
這實際上意味着你的控制器是從app.js初始化的,然後這些控制器負責處理你通常放在onReady()中的代碼,以將函數綁定到事件。 'views'的概念就是你放置widget代碼的地方。
E.g.
app.js
Ext.application({
name: 'MyApp',
appFolder: '/MyApp/Scripts',
autoCreateViewport: true,
requires: [
//data
'ALES.controller.MyController',
]
});
MyController.js
Ext.define('ALES.controller.MyController', {
extend: 'Ext.app.Controller',
id: 'MyController',
views: [
'MyView'
],
stores: [
'MyStore'
],
init: function() {
this.control(
{
'panel > button': { click: this.myClickHandler }
});
});
MyView.js
Ext.define('MyApp.view.MyView', {
extend: 'Ext.form.Panel',
id: 'MyView',
requires: [
'Ext.grid.plugin.CellEditing' //or other Ext stuff you want to include
],
constructor: function (config) {
this.initConfig(config);
return this.callParent(arguments);
},
initComponent: function() {
Ext.apply(this, {
items: this.createControls()
});
this.callParent();
},
createControls: function() {
return [{
xtype: 'panel',
items: [{
xtype: 'button'
}]
}
];
}
});
的一些體面的GUI DES在煎茶網站,我建議你進行更深層次的理解通讀:
http://docs.sencha.com/extjs/4.1.3/#!/guide/application_architecture
感謝,沒有工作!在此之前,我依靠jQuery的getScript() – 2013-04-18 07:31:43
上面的代碼在Chrome和Mozilla上運行良好,但在IE中我得到「網頁錯誤詳情 消息:'processed'爲空或不是對象 Line:101634 Char:13 Code :0 URI:ext-all-debug.js 「 – 2013-04-18 07:39:57