我正在以编程方式创建 DOJO TabContainer 和 ContentPanes 以添加到该 tabContainer。每个 contentPanes 都包含我的自定义小部件。部分代码如下所示。显示选项卡时,第一个选项卡上的 containerNode 的高度为 0px,因此即使第一个选项卡具有完全加载的小部件,但它不会显示在浏览器中。这曾经在 1.6 中正常工作。我已将 dojo 1.6 替换为 1.9.3 并遇到了这个问题。有任何想法吗?
var availableWidgets = {
'Name': {title: 'Name', widget:'test.ui.NameWidget'},
'Stats': {title: 'Stats', widget:'test.ui.StatsWidget'}
};
postCreate: function(){
var tabContainer = new dijit.layout.TabContainer({controllerWidget: "dijit.layout.TabController"}, this.pContainerDiv);
tabContainer.set('class', 'claro');
tabContainer.set('doLayout', false);
tabContainer.set('style', "width: 100%; height: 100%;");
dojo.forEach(this.menuItems, dojo.hitch(this, function(menuItem, index){
var widgetInfo = availableWidgets[menuItem];
if(widgetInfo != null){
var contentPaneId = portletNamespace + pContext.persistentId + menuItem + 'ContentPane';
var contentPane = new dijit.layout.ContentPane({
id: contentPaneId,
title: widgetInfo.title,
selected: currentSelectedItem == menuItem,
closable: false,
style: 'height:100%;padding: 15px;',
onShow: dojo.hitch(this, function(){
//can no longer do this in 1.9
//dojo.require(widgetInfo.widget);
if (widgetInfo.widget == 'test.ui.NameWidget') {
dojo.require("test.ui.NameWidget");
} else if (widgetInfo.widget == 'test.ui.StatsWidget') {
dojo.require("test.ui.StatsWidget");
}
var currentView = this.widgets[widgetInfo.title];
if(!currentView){
currentView = eval('new ' + widgetInfo.widget + '(this.params)');
currentView.placeAt(contentPaneId, 'last');
// startup called by (dijit/_WidgetBase in 1.9.3) by placeAt above
// currentView.startup();
this.widgets[widgetInfo.title] = currentView;
}
})
});
tabContainer.addChild(contentPane);
}
}));
}