由于埃文说,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