dojo 1.8: Error: Tried to register widget with id=

2019-02-26 00:04发布

问题:

Hi I have a simple one as shown below that displays bordercontainer and contentpane. I do not understand why the bordercontainer's id is registered twice since I only have one id defined for bordercontainer.

The error stated: Error: Tried to register widget with id==main_bContainer but that id is already registered Please advise where I got it wrong.

<!DOCTYPE html>
<html>
<head>
<title>Hello</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../dojo1_8/dijit/themes/soria/soria.css"/>
<link rel="stylesheet" href="../common.css"/>
<style type="text/css">
html, body 
{
    width: 100%;
    height: 100%;
    margin: 5px;
    padding: 0px;
    overflow: hidden;
}

</style>



</head>

<body class="soria">
<div id="main_bContainer" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar'">
    <div class="cP_Left" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
        Content Pane A
    </div>
    <div class="cP_Right" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'right'">
        Content Pane B
    </div>

</div>
</body>

<script>            
var dojoConfig =
            {
                parseOnLoad: true,//replace web controls based on theme soria
                isDebug: true,//true for debuggin with aid  from FireBug, Always set it to false, to avoid overhead
                async: true,//
                locale : "en-us"//
            }; 
</script>

<script src='../dojo1_8/dojo/dojo.js'></script>

<script>require(["dojo/parser",
             "dojo/ready",
             "dojo/request",
             "dijit/layout/BorderContainer",
             "dijit/layout/ContentPane",
             "dojo/domReady!"
            ], function(parser, ready, request)
            {ready(function()
                {parser.parse();




            });
    });
</script>
</html>

Thanks Clement

回答1:

Becuase you have parse() its 2 times.

Here dojoConfig = { parseOnLoad: true };

and here parser.parse();

Just parse only one the problem will solve.



标签: dojo