3
我試圖'需要'加載程序的一些代碼,但我當前的onready函數給我的要求(它抱怨尚未創建的視口)的悲傷。由於我將內容分配給創建時的視口,因此我無法真正需要我填充的內容(除非我創建視口並將其分配給它,但是meh)。當init函數創建視口時,人們如何做Ext.Require?
這是怎麼回事我Ext.require []與這樣的功能? (或者我怎麼能重組這個功能,因此它執行相同的方式,同時讓我的陣列上運行Ext.Require?)
Host=function(){
return{
centerPanelId: 'mainLayoutCenter',
init: function(){
//Enable the loader for dynamic loading of js, only dev pls
Ext.Loader.setConfig({enabled:true});
Ext.QuickTips.init(); //ext needs this
Ext.Loader.setPath("bleh","js/bleh"); //Project paths for the loaders
if(!window.User){
this.initialContent = Ext.create('bleh.Login');
}
//Our default View
//this.initialContent = Ext.create('bleh.panel.Register');
this.currentContent=this.initialContent;
//Instantiate a viewport
this.viewport = Ext.create("bleh.viewport",{
initialContent : this.initialContent
,host:this
});
//init function, to hande events for HTML elements etc
//bleh.init();
}
,setContent: function(contentPanel){
var center = Ext.getCmp(this.centerPanelId);
if (this.currentContent) { center.remove(this.currentContent); }
this.currentContent = contentPanel;
center.add(this.currentContent);
center.doLayout();
this.currentContent.show();
}
}
}();
Ext.onReady(Host.init, Host);