Border Container not working as expecteed in dojo

173 views Asked by At

I am trying basic example of bordercontainer in dojo and below is the html code for it, but it does not show the required output. Can anyone tell me what I am doing wrong here. This sample code I have taken from dojo tutorial only and also I am not getting any error as well in firebug.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>ICN Layout</title>

</head>
<body>
  <!-- load Dojo -->
  <script>dojoConfig = {parseOnLoad: true}</script>
  <script src="dojo/dojo.js">
  </script>
  <script>
   require([
   "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
   "dojo/domReady!"
   ], function(BorderContainer, ContentPane){
   // create a BorderContainer as the top widget in the hierarchy
   var bc = new BorderContainer({
    style: "height: 300px; width: 500px;"
   });

   // create a ContentPane as the left pane in the BorderContainer
   var cp1 = new ContentPane({
    region: "left",
    style: "width: 100px",
    content: "hello world"
   });
   bc.addChild(cp1);

   // create a ContentPane as the center pane in the BorderContainer
   var cp2 = new ContentPane({
    region: "center",
    content: "how are you?"
   });
   bc.addChild(cp2);

   // put the top level widget into the document, and then call startup()
   bc.placeAt(document.body);
   bc.startup();
   });
  </script>
</body>
</html>
2

There are 2 answers

3
Kyle Dodge On

I don't know if your dojo/dojo.js file is loading correctly, but I don't see the needed dojo css files in your code. Make sure to include those (based on the theme you are using). for example:

<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css'>

<link rel='stylesheet' href='http://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css'>

Here are two working examples that show your code working:

Pen: http://codepen.io/kyledodge/pen/RPVjgY

Fiddle: http://jsfiddle.net/6v0x0jue/2/

0
Paul Wu On

Have you properly downloaded and put all the required dojo dijit dojox folders ? And then, you can include the css locally:

<link rel="stylesheet" href="dijit/themes/claro/claro.css" media="screen">
<link rel="stylesheet" href="dojo/resources/dojo.css">

I saw that the code is working without any problem, if you add this code:

    // create a ContentPane as the Top pane in the BorderContainer
    var cp0 = new ContentPane({
        region: "top",
        content: "This is The Top!"
    });
    bc.addChild(cp0);

you can see that the cp0 ContentPane is placed on Top without any problem... I guess you want to see the borders (and perhaps background-color) to visualize the area?