如何让jstree工作

时间:2010-08-23 17:37:23

标签: javascript jquery jstree

这是我的档案omploader.org/vNWJieg/1.png:

这是我的代码:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>jsTree v.1.0 - full featured demo</title>
 <script type="text/javascript" src="_lib/jquery.js"></script>
 <script type="text/javascript" src="_lib/jquery.cookie.js"></script>
 <script type="text/javascript" src="_lib/jquery.hotkeys.js"></script>
 <script type="text/javascript" src="jquery.jstree.js"></script>
 <link rel="stylesheet" type="text/css" href="_docs/!style.css" />
 <style type="text/css">
 html, body { margin:0; padding:0; }
 body, td, th, pre, code, select, option, input, textarea { font-family:verdana,arial,sans-serif; font-size:10px; }
 .demo, .demo input, .jstree-dnd-helper, #vakata-contextmenu { font-size:10px; font-family:Verdana; }
 #container { width:780px; margin:10px auto; overflow:hidden; position:relative; }
 #demo { width:auto; height:400px; overflow:auto; border:1px solid gray; }

 #text { margin-top:1px; }

 #alog { font-size:9px !important; margin:5px; border:1px solid silver; }
 </style>
</head>
<body>
<div id="demo1">
 <a href="some_value_here">Node title</a>
 <ul>
  <li>
   saaa
   <!-- UL node only needed for children - omit if there are no children -->
   <ul>
    <li>aaa</li>
    <li>sss</li>
   </ul>
  </li>
 </ul>

</div>
<script type="text/javascript">
 $(function () {
 $("#demo1").jstree({ 
  "themes": {
         "theme": "default",
         "dots": true,
         "icons": true,
         "url": "themes/default/style.css"
       },
  "plugins" : [ "themes", "html_data" ]
 });
});
</script>
</body>
</html>

我的结果是omploader.org/vNWJibg:

你可以看到,它没有任何主题,

所以如何让它发挥作用,

感谢

更新

这是我的结果pic:omploader.org/vNWJjbQ/1.png

如何让它发挥作用。

updated2

哦,我明白了,它必须是<a>

中的<li>元素

这是我的代码:

<div id="demo1">
    <ul>
        <li>
            <a href="">aaa</a>
            <!-- UL node only needed for children - omit if there are no children -->
            <ul>
                <li><a href=""> kkk</a></li>
                <li><a href=""> kkk</a></li>
            </ul>
        </li>
    </ul>

</div>

1 个答案:

答案 0 :(得分:2)

看起来您的div上没有ID。将<div id="">更改为<div id="demo1">