Height of tabContainers in dojo
If you set the property doLayout
to false on either the ContentPane or the TabContainer it should automatically size the height to the content. The doLayout
property of the dijit layout containers defaults to true, which then requires a specific height to be applied to it.
DOJO TabContainer containerNode height is 0px
I have a fix. Before adding the content panes to the tab container, I now call:
tabContainer.startup();
When using dojo 1.6, I was doing this after all the content panes were added to the tab container. Calling this before fixes the height issue and renders all tabs correctly using dojo 1.9.3.
Dojo and heights of widgets
For Q1, the documentation says :
The outer size must be specified on the BorderContainer node. Width must be specified for the sides and height for the top and bottom, respectively. No dimensions should be specified on the center; it will fill the remaining space.
In your CSS, you are setting the appContainer to take the full screen, because a height of 100% means 100% of the parent element... and your structure is
<html><body><div id="appContainer">...etc
Therefore, you have to set both body and html to 100% if you want your appContainer to take 100% of the screen height...
By default, block elements are already 100% wide, so no need to set the width there...
For Q2, I suggest you have a look at your html in firebug. You will notice a div with id="bookingDojo", which will be the outmost div of your template. The first inner div has a class="bookingDojo". Again, these 2 divs are nested, and for that reason, they both need to be set to a height of 100% if you want them to fill-in the full height of their parent container div (which is your BorderContainer, which you already set to be 100% high). I made a little example here http://jsfiddle.net/psoares/7JQWC/
You will see something like your bookingDojo where I set #bookingDojo to 100% height, but didn't specify a height for the .bookingDojo class. Try to set it and you will see the red border expand...
For Q3, well, I think the whole issue here is understanding how nested boxes get their sizes, so for that you can refer to Q1 and Q2...
I hope this helps...
Make dijit TabContainer tabs same size and evenly stretch them to the size of the tab container
It's Simple just locate the class and apply style to it.
To do it dynamicly whatever number of tabs you have :
- Calculate The number of childs
- Calculate the width of the tabContainer
- Apply to all child the calculated whidth ( whidth container / number of childs - other stuff)
- Create
window resize
change event to make thewidth
dynamic
Here is a solution :
require([ "dojo/query", "dojo/on", "dojo/dom-style", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dojo/domReady!"], function(query,On,domStyle,TabContainer,ContentPane) { var tc = new TabContainer({ style: "height: 100px; width: 100%;" },"tabContainer");
var cpOrg = new ContentPane({ title: "Mississippi", content: "Mississippi" }); tc.addChild(cpOrg); var cpShared = new ContentPane({ title: "Utah", content: "Utah" }); tc.addChild(cpShared);
var cpPrivate = new ContentPane({ title: "New York", content: "New York" }); tc.addChild(cpPrivate); tc.startup(); changeTabWidth(); function changeTabWidth(){ // get the number of child of tabContainer var number_of_child = tc.containerNode.childElementCount; // calculate width of tabContainer and divide by number of child then // every tab has 6px left and right padding + 1px border right so // size must be 6+6+3-1 for the last tab = "14" that's why we remove 14 above from the width sum var width = (domStyle.get(tc.containerNode,"width")/number_of_child) - 14; query(".dijitTabInner.dijitTabContent.dijitTab").forEach(function(element){ domStyle.set(element, { width: width+"px" }); }); } // event to change width after window size changed On(window,"resize",function(){ changeTabWidth(); }) });
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.11.2/dojo/dojo.js"></script><link href="https://ajax.googleapis.com/ajax/libs/dojo/1.10.0/dijit/themes/claro/claro.css" rel="stylesheet"/><div class="claro"> <div id="tabContainer"></div></div>
Sub-widgets won't render (will have 0 height) in Dojo
Indeed there is a typo, as Frode mentioned, but you will still need to click one of the tabs if you want your tab content to appear in the SubWidget
.
I suggest that you correct the typo and make your widget subclass ContentPane
rather than _WidgetBase
to solve this issue, as ContentPane
s know how to resize themselves, like this :
declare('SubWidget', [ContentPane, _TemplatedMixin, _WidgetsInTemplateMixin], {
templateString: ''...
See http://jsfiddle.net/psoares/YwWst/
By the way, there is no need to specify widgetsInTemplate : true
in 1.8. Adding _WidgetsInTemplateMixin
is enough...
TabContainer displays Tabs only at windowresize
Some notes to your code:
The region
attribute is here not required. Its only used to indicate the position for BorderContainer children.
var bordercontainer = new dj_BorderContainer({
style: "height: 100%; width: 100%;",
gutters: false,
region: "top"
});
You don't need to set a width and height on your ContentPane, let this do the TabContainer.
var contentpane = new dj_ContentPane({
title: "Calculation " + (i + 1),
content: "content",
style: "height: 100%; width: 100%;"
});
I've created a sample for you, maybe this helps you out.
require(["dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/ContentPane", "dojo/domReady!"],function(BorderContainer, TabContainer, ContentPane) { // first create the BorderContainer without any arguments. let bc = new BorderContainer({}, "bc"); // then create your TabContainer with region center. let tc = new TabContainer({ region: 'center' }, document.createElement("div")); // add it to your BorderContainer bc.addChild(tc); // then create three tab panes (ContentPane) and add them to your TabContainer let cp = new ContentPane({ content: "My tab pane!", title: "My tab title" }, document.createElement("div")); tc.addChild(cp); let cp2 = new ContentPane({ content: "My second tab pane!", title: "My second tab title" }, document.createElement("div")); tc.addChild(cp2); let cp3 = new ContentPane({ content: "My closable tab pane!", title: "My closable tab title", closable: true }, document.createElement("div")); tc.addChild(cp3); // call startup on your BorderContainer. startup of BorderContainer will call also the startup methods of all children (TabContainer, ContentPane's). bc.startup();
});
body, html { height: 100%; width: 100%; overflow: hidden; margin: 0 auto;}
<link href="//ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/tundra/tundra.css" rel="stylesheet"/><script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script><span class="tundra" style="width: 100%; height: 100%;"> <div id="bc" style="width: 100%; height: 100%;"></div></span>
dojo 1.10.4 dijit/layout/Tabcontainer not rendering first contentpane's content
This issue appears when you already parsed the TabContainer
and you're trying to parse it again. What happens is that the new widget cannot be created because it already exists, and so your first tab will not work correctly.
If you open your browser console (usually F12), you'll even see the error:
dojo/parser::parse() error Error: Tried to register widget with id==dijit_layout_ContentPane_0 but that id is already registered
To fix this you should try to look for other parser.parse()
statements, or perhaps you're parsing the DOM on load already (using parseOnLoad: true
) if that's the case, you don't need to do additional parsing.
Related Topics
iOS 10.3 Safari Text-Align:Justify Bug for Persian/Arabic Content
Why Do My Icons Line Up Top-To-Bottom Instead of Flowing Left-To-Right in a Div Layout
Correct Way for Writing an <Address> Tag for My Web Site, to Provide Contact Details for Our Company
How to Set The Current Frame (Or Similar) of a CSS Animation
Display Optgroup Label as Initial Option
Break an Absolutely Positioned Element Out of Its Relatively Positioned Ancestor
Center Div Vertically in Flexbox Container with Stretch Alignment
CSS3 Transform: Translate3D Doesn't Affect The Z-Axis
How Do Make Ionic 4 Ion-Col The Same Height
CSS Layout Help - Stretch Div to Bottom of Page
Jekyll Liquid Variables as Inline CSS Values
Avoid an Image to Go Outside a Div
How to Have "Margin:Auto" and "Margin-Left:Offset" Working Together
How to Keep a Div Always on The Screen, But Not Always in a Fixed Position