function SelectTree(req,first){ var setting = { view: { dblClickExpand: false }, data: { simpleData: { enable: true } }, callback: { beforeClick: req.beforeClick } }; $("#Sel").click(function(){ var cityObj = $("#Sel"); var cityOffset = $("#Sel").offset(); if(req.isbox){ $("#menuContent").slideDown("fast"); }else{ $("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast"); } }) doAjaxPostData(req.method, localUrl+req.url,req.data,function(data){ if(data.status == 10001){ var arr = data.data; var node = new Array(); if(first == "" || first == 'undefined' || first == undefined){ var i=0; } else{ var i=1; arr[0] = {"id":first.id,"pId":first.pId,"name":first.name} } for(i in arr){ if(arr[i].parent_id == undefined || arr[i].parent_id == "undefined"){ arr[i].parent_id = 1; } node[i] = {"id":arr[i].id,"pId":arr[i].parent_id,"name":arr[i].name,"open":true}; } $.fn.zTree.init($("#tree"), setting, node); }else{ } }); }