1

我想知道为什么 dojo 不响应元素的更改?我做了一个简单的例子来展示我的问题!

<html >
<head>
    <script>dojoConfig = {parseOnLoad: true}</script> 
    <script src='../dojo/dojo.js'></script>
    <script>
        require([
            "dijit/layout/BorderContainer",
            "dijit/layout/ContentPane"
        ]);
        require(["dojo/dom","dojo/on","dojo/domReady!"], function(dom, on){

            on(dom.byId("tester"),"resize", function() { console.log('window on resize') });

        });
    </script>
</head>
<body>
<div data-dojo-type="dijit/layout/ContentPane" style="width: 50%;" >
    <div data-dojo-type="dijit/layout/BorderContainer" id="tester">
    </div>
</div>
</body>
</html>

使用时一切正常,on(window,"resize", function());但我不知道为什么上面的示例不起作用。

4

1 回答 1

0

试试这个(使用方面而不是开):

<html >
<head>
    <script>dojoConfig = {parseOnLoad: true}</script> 
    <script src='../dojo/dojo.js'></script>
    <script>
        require([
            "dijit/layout/BorderContainer",
            "dijit/layout/ContentPane"
        ], function(BC, CP){
        require(["dojo/aspect","dojo/domReady!"], function(aspect){

            var bc= new BC({}, "tester");

            bc.startup();

            aspect.after(bc, "resize", function() { console.log('window on resize') });


        });
        });    
    </script>
</head>
<body>
    <div id="tester" style="width: 50%;height:100%;">
    </div>
</body>
</html>
于 2013-09-27T14:49:43.723 回答