我和 Sencha 一起去 MVC 路线。我有一个像 twitter 示例一样初始化的视口面板:
/**
* @author Jeff Blake
*/
Ext.regApplication('App', {
defaultTarget: 'viewport',
defaultUrl : 'Viewport/index',
name : 'App',
icon : "mobile/public/resources/images/icon.png",
phoneStartupScreen : "mobile/public/resources/images/phone_startup.png",
//useHistory : false,
//useLoadMask : true,
launch: function() {
Ext.Viewport.init();
Ext.Viewport.onOrientationChange();
this.viewport = new App.Viewport({
application: this
});
Ext.dispatch({
controller: 'User',
action : 'index'
});
}
});
/**
* @class App.Viewport
* @extends Ext.Panel
* This is a default generated class which would usually be used to initialize your application's
* main viewport. By default this is simply a welcome screen that tells you that the app was
* generated correctly.
*/
App.Viewport = Ext.extend(Ext.Panel, {
id : 'viewport',
layout : 'card',
fullscreen: true,
cardSwitchAnimation: 'slide',
initComponent: function() {
Ext.apply(this, {
dockedItems: [
{
// Top Bar
dock : 'top',
xtype : 'toolbar',
title : 'Whats Good',
items: [
{
text: 'About'
},
]
}
]
});
App.Viewport.superclass.initComponent.apply(this, arguments);
}
});
Ext.reg('App.Viewport', App.Viewport);
新代码:
if (!App.viewport.getDockedComponent(homeBar)) {
var homeBar = new App.HomeBar();
App.viewport.addDocked(homeBar);
}
我希望能够根据当前在视口中呈现的面板类型有条件地应用停靠项(工具栏)。EG:一个用于登录、主屏幕、详细信息屏幕等。
我试过使用 Ext.apply(App.Viewport, { dockedItems: [App.LoginBar]}); 但这不起作用。目前它可以将工具栏添加到当前渲染的面板并将其设置为全屏,但不幸的是,转换和事情的行为很奇怪,因为结构是
Panel
Toolbar
Panel
Toolbar
/end Panel
/end Panel
有人有建议吗?