treecase.htm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title></title>
  5. <script src="../../lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
  6. <link href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
  7. <script src="../../lib/ligerUI/js/core/base.js" type="text/javascript"></script>
  8. <script src="../../lib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
  9. <script src="../../lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
  10. <script type="text/javascript">
  11. var manager = null;
  12. $(".l-tree .l-body span").live('mouseover', function (e) {
  13. if (!this.title)
  14. this.title = $(this).text();
  15. });
  16. $(function ()
  17. {
  18. $("#tree1").ligerTree(
  19. {
  20. url: 'tree.json',
  21. nodeWidth : 40,
  22. onBeforeExpand: onBeforeExpand,
  23. onExpand: onExpand
  24. });
  25. manager = $("#tree1").ligerGetTreeManager();
  26. });
  27. function onBeforeExpand(note)
  28. {
  29. if (note.data.children && note.data.children.length == 0)
  30. {
  31. //这里模拟一个加载节点的方法,append方法也用loadData(target,url)代替
  32. manager.append(note.target, [
  33. { text: note.data.text + "'s child1" },
  34. { text: note.data.text + "'s child2" },
  35. { text: note.data.text + "'s child3" }
  36. ]);
  37. }
  38. }
  39. function onExpand(note)
  40. {
  41. }
  42. </script>
  43. </head>
  44. <body style="padding:10px">
  45. <h4>模拟异步动态加载节点</h4>
  46. <div style="width:400px; height:500px;">
  47. <ul id="tree1" >
  48. <li isexpand="false"><span>第一个节点</span><ul></ul></li>
  49. <li isexpand="false"><span>第二个节点</span><ul></ul></li>
  50. </ul>
  51. </div>
  52. <div style="display:none">
  53. </div>
  54. </body>
  55. </html>