Dojo树与复选框不显示 [英] Dojo tree with checkbox not displaying

查看:251
本文介绍了Dojo树与复选框不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这让我疯狂。树根本不显示。
这里是代码

This is driving me crazy. The tree is not displaying at all. Here is the code

<html>
<head>
<meta charset="utf-8">
<title>The CheckBox Tree with multi-parented Eventable Store</title>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
<link rel="stylesheet" href="dojo/dijit/themes/claro/claro.css" type="text/css"/>
<link rel="stylesheet" href="cbtree/themes/claro/claro.css" type="text/css"/>
<script> dojoConfig = {async: true, parseOnLoad: true};</script>

  <script>
 var myData = [
 { name:"Family"    , type:"root"                                           },
 { name:"Abe"       , type:"parent", parent:["root"]         , hair:"Brown" },
 { name:"Jacqueline", type:"parent", parent:["root"]         , hair:"Brown" },
 { name:"Homer"     , type:"parent", parent:["Abe"]          , hair:"none"  },
 { name:"Marge"     , type:"parent", parent:["Jacqueline"]   , hair:"blue"  },
 { name:"Bart"      , type:"child" , parent:["Homer","Marge"], hair:"blond" },
 { name:"Lisa"      , type:"child" , parent:["Homer","Marge"], hair:"blond" },
 { name:"Maggie"    , type:"child" , parent:["Homer","Marge"], hair:"blond" }
  ];

required(["cbtree/store/Hierarchy",         
      "cbtree/model/TreeStoreModel",     
      "cbtree/Tree",
      "dojo/dojo/ready"
     ], function (Hierarchy, TreeStoreModel, Tree) {

  // Create the store and load it with our data set.
  var myStore = new Hierarchy( { data:myData } );
 var myModel = new TreeStoreModel({ store:myStore, query:{type:"root"} });
 var myTree  = new Tree( { model:myModel }, "CheckBoxTree" );
 myTree.startup();
});
 </script>
</head>
<body class="claro">
<h1 class="DemoTitle">The CheckBox Tree with Multi State CheckBoxes</h1>
<div id="CheckBoxTree" style="width:300px; height:300px; border-style:solid; border-width:medium;">
</div>
</body>
</html>

任何人都有任何线索?进口都很好。
我有这样的根目录中的文件夹:

Anyone have any clue? The imports are all fine. I have the folders in the root like this:

dojo / dojo

dojo/dojo

dojo / dijit

dojo/dijit

cbtree /

感谢

推荐答案

需要 ing dojo / dojo / ready 使用它。我想你需要在 ready(function(){...})或者使用 dojo / domReady!插件等待dom在你与它交互之前就准备好了。注意使用 require 而不是 required ,并包含就绪

You're requireing dojo/dojo/ready, but you're not using it. I think you need to either wrap your tree creation in ready(function(){...}) or use the dojo/domReady! plugin to wait for the dom to be ready before you interact with it. Note the use of require as opposed to required and the inclusion of ready in the require callback in the first example.

dojo / ready

require(["cbtree/store/Hierarchy",         
      "cbtree/model/TreeStoreModel",     
      "cbtree/Tree",
      "dojo/dojo/ready"
], function (Hierarchy, TreeStoreModel, Tree, ready) {
    ready(function() {
        // Create the store and load it with our data set.
        var myStore = new Hierarchy( { data:myData } );
        var myModel = new TreeStoreModel({ store:myStore, query:{type:"root"} });
        var myTree  = new Tree( { model:myModel }, "CheckBoxTree" );
        myTree.startup();
    }
});

dojo / domReady!

require(["cbtree/store/Hierarchy",         
      "cbtree/model/TreeStoreModel",     
      "cbtree/Tree",
      "dojo/dojo/domReady!"
], function (Hierarchy, TreeStoreModel, Tree) {
    // Create the store and load it with our data set.
    var myStore = new Hierarchy( { data:myData } );
    var myModel = new TreeStoreModel({ store:myStore, query:{type:"root"} });
    var myTree  = new Tree( { model:myModel }, "CheckBoxTree" );
    myTree.startup();
});

这篇关于Dojo树与复选框不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆