无法在dojo选项卡中加载启用dojo的页面

时间:2014-07-29 07:50:28

标签: dojo

我有两页 viewport1.html

<!DOCTYPE html>
<html >
<head>

    <link rel="stylesheet" href="js/lib/dijit/themes/claro/claro.css">
    <style type="text/css">
html, body {
    width: 100%;
    height: 100%;
    margin: 0;
}
    </style>
    <script>dojoConfig = {parseOnLoad: true}</script>
    <script src='js/lib/dojo/dojo.js'></script>

    <script>
require(["dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionPane"]);
    </script>
</head>
<body class="claro">
    <div data-dojo-type="dijit/layout/BorderContainer" style="width: 100%; height: 100%;">
     <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">Top pane</div>
     <div data-dojo-type="dijit/layout/AccordionContainer" data-dojo-props="region:'leading'">
          <div data-dojo-type="dijit/layout/AccordionPane" title="pane #1">accordion pane #1</div>
          <div data-dojo-type="dijit/layout/AccordionPane" title="pane #2">accordion pane #2</div>
          <div data-dojo-type="dijit/layout/AccordionPane" title="pane #3">accordion pane #3</div>
     </div>
     <div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="region:'center'">
          <div data-dojo-type="dijit/layout/ContentPane" title="tab #1">tab pane #1</div>
          <div data-dojo-type="dijit/layout/ContentPane" title="tab #2" href="index.html">tab pane #2</div>
          <div data-dojo-type="dijit/layout/ContentPane" title="tab #3">tab pane #3</div>
     </div>
     <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'trailing'">Trailing pane</div>
     <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">Bottom pane</div>
</div>
</body>
</html>

的index.html

<!DOCTYPE html>
<html >
<head>

    <link rel="stylesheet" href="js/lib/dijit/themes/claro/claro.css">
    <!-- script>
    var dojoConfig = {
    baseUrl: "/site/mysite/js/",
    tlmSiblingOfDojo: false,
    packages: [
        { name: "dojo", location: "lib/dojo" },
        { name: "dijit", location: "lib/dijit" },
        { name: "dojox", location: "lib/dojox" }
    ]
};
    </script-->
    <script type="text/javascript" src="js/lib/dojo/dojo.js" data-dojo-config="isDebug:true, parseOnLoad: true"></script>
    <script type="text/javascript">
        dojo.require("dijit.dijit");
        dojo.require("dojox.grid.DataGrid");
        dojo.require("dojo.data.ItemFileWriteStore");
        dojo.require("dojo.parser");
    </script>
    <script>
require(["dojo/data/ItemFileWriteStore", "dojox/grid/DataGrid", "dijit/layout/BorderContainer", "dojox/layout/ContentPane","dojo/domReady!"], function(ItemFileWriteStore, DataGrid, BorderContainer, ContentPane){
    // create a BorderContainer as the top widget in the hierarchy
    var bc = new BorderContainer({
        style: "height: 500px; width: 700px;"
    });

    // 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",
        href: "center.html"
    });
    bc.addChild(cp2);

    // put the top level widget into the document, and then call startup()
    bc.placeAt('div1');

    bc.startup();
    cp2.startup();

});
    </script>
</head>
<body class="claro">
    <div id="div1"></div>
</body>
</html>

我正在尝试在viewport1.html页面的一个标签页面中加载index.html。但是index.html页面没有被渲染。

感谢任何帮助。我的要求是动态地在另一个启用dojo的页面中加载启用了dojo的页面。

1 个答案:

答案 0 :(得分:0)

我在代码示例下面找到了我想要的东西。我想我应该使用声明式而不是编程式方法。

<!DOCTYPE html>
<html >
    <head>

        <link rel="stylesheet" href="js/lib/dijit/themes/claro/claro.css">
        <style type="text/css">
            html, body {
                width: 100%;
                height: 100%;
                margin: 0;
            }
        </style>
        <script>dojoConfig = {parseOnLoad: true}</script>
        <script src='js/lib/dojo/dojo.js'></script>
        <script>
            require(["dojo/parser", "dijit/layout/BorderContainer", "dijit/layout/TabContainer", "dijit/layout/AccordionContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionPane"]);
        </script>
    </head>
    <body class="claro">
        <div data-dojo-type="dijit/layout/BorderContainer" style="width: 100%; height: 100%;">
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">Top pane</div>
         <div data-dojo-type="dijit/layout/AccordionContainer" data-dojo-props="region:'leading'">
              <div data-dojo-type="dijit/layout/AccordionPane" title="pane #1">accordion pane #1</div>
              <div data-dojo-type="dijit/layout/AccordionPane" title="pane #2">accordion pane #2</div>
              <div data-dojo-type="dijit/layout/AccordionPane" title="pane #3">accordion pane #3</div>
         </div>
         <div data-dojo-type="dijit/layout/TabContainer" data-dojo-props="region:'center'">
              <div data-dojo-type="dijit/layout/ContentPane" title="tab #1">tab pane #1</div>
              <div data-dojo-type="dijit/layout/ContentPane" title="tab #2" href="bordercontainer.html" parseOnLoad="true" preLoad="false">tab pane #2</div>
              <div data-dojo-type="dijit/layout/ContentPane" title="tab #3">tab pane #3</div>
         </div>
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'trailing'">Trailing pane</div>
         <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">Bottom pane</div>
        </div>
    </body>
</html>