1 html2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">4 5 6 7 jsTree»Demos8 9 10 11 12 13 14 15 16 18 19 20 21 23 24 26 27 28 29 30 html,body{31 margin:0;32 padding:0;33 }34 35 body,td,th,pre,code,select,option,input,textarea{36 font-family:"Trebuchet MS", Sans-serif;37 font-size:10pt;38 }39 40 #container{41 width:800px;42 margin:10px auto;43 overflow:hidden;44 }45 46 .demo{47 height:200px;48 width:300px;49 float:left;50 margin:0;51 border:1px solid gray;52 font-family:Verdana;53 font-size:10px;54 background:white;55 overflow:auto;56 }57 58 .code{59 width:490px;60 float:right;61 margin:0 0 10px 0;62 border:1px solid gray;63 }64 65 pre{66 display:block;67 }68 69 .syntaxhighlighter{70 margin:0 0 0 0 !important;71 padding:0 !important;72 }73 74 75 76 77 Async JSON demo78
Same as with the HTML datastore you can load data from a file.
79 80 varstat=[81 { attributes : {"id":"node_1"}, data :"Node 1"},82 { attributes : {"id":"node_2"}, data :"Node 2", state :"closed"},83 { attributes : {"id":"node_3"}, data :"Node 3", state :"closed"}84 ];85 $(function() {86 $.ajaxSetup({cache:false});//ajax调用不使用缓存87 $("#async_json_1").tree({88 data : {89 type :"json",90 async :true,91 opts : {92 async :true,93 method :"GET",94 url :"async_json_data.json"95 }96 },97 lang:{98 loading:"目录加载中……"//在用户等待数据渲染的时候给出的提示内容,默认为loading99 },100 ui:{101 theme_name:'classic'//设置样式102 },103 callback : {104 //Make sure static is not used once the tree has loaded for the first time105 onload :function(t) {106 t.settings.data.opts.static=false;107 },108 //n--节点,t是tree109 beforedata :function(n, t) {110 if(n==false)111 t.settings.data.opts.static=stat;112 else113 return{parent_Id/*参数名称*/: $(n).attr("id")||false}//AJAX调用参数传递114 }115 },116 //插件使用右键菜单支持自定义右键菜单117 plugins:{118 contextmenu:{}119 }120 121 });122 });123 124 125 126 127