jstree添加节点

//生成时间搓作为文档id
var id = new Date().getTime().toString();

function uploadSubmit() {

//判断上传文件和节点名称是否为空
  var AddNodeTextUrl_file = $("#AddNodeTextUrl_file").val();
  var AddNodeTextId = $("#AddNodeTextId").val();
if(AddNodeTextUrl_file == ""){
   alert(Add_Node_Text_Url_file);
    return false;
}
else if (AddNodeTextId == "") {
   alert(Add_Node_Text_Id);
return false;
}
   //获取文档名称
  var name = $("#AddNodeTextId").val();
 
  var libId = $("#libId").val();
  var libVersion = $("#libVersion").val();
 
 
  //获取当前上传的文档名称
  var urlNum = AddNodeTextUrl_file.lastIndexOf("\\");
  var url = AddNodeTextUrl_file.substring(urlNum,AddNodeTextUrl_file.length);
  url = url.replace("\\","/");

  //获取节点类型
  var type = $("#addMenu_select_node_type").val();
  //获取排列顺序
  var pos = $("#addMenu_select_sort").val();
 
  var position = "";
 
  if(type == "兄弟节点" && pos == "之前"){
    position = "before";
  }
  else if(type == "兄弟节点" && pos == "之后"){
      position = "after";
  }
  else if(type == "子节点" && pos == "之前"){
      position = "first";
  }
  else if(type == "子节点" && pos == "之后"){
    position = "last";
  }
 
  //添加节点时给li 和 a标签赋属性值
  var js = {
  attr : { id : id , libid : libId, libv : libVersion, sub : 1, stata : "", url : ""},
  data : {//showHtmlContent('topics/BSS角色场景map090819B1.doc','1282902377544')
  attr:{'class' : "li-a-b", style : "cursor: pointer;", onclick : "showHtmlContent(\'topics"+url+"\'"+",\'"+id+"\')", target : "cFrame_110", unselectable: "on"},
  // title: "<span onclick=\"getHtmlContent(\'" + id +"\')\">" + name + "</span>"
  title: name
  }
  };
  //调用create函数
$("#demo").jstree("create",checkNode,position,js,null,name);

//获取上传文档类型
var type = AddNodeTextUrl_file.indexOf(".");
var typeStr = AddNodeTextUrl_file.substring(type,AddNodeTextUrl_file.length);

//给新创建节点id隐藏域赋值
    $("#Id").attr("value",id);
//给新创建节点名称隐藏域赋值
    $("#AddNodeTextName1").attr("value",AddNodeTextId);
//给新创建节点类型隐藏域赋值
    $("#selectNodeType").attr("value",$("#addMenu_select_node_type").val());
//给新创建节点排序隐藏域赋值
    $("#selectNodePos").attr("value",$("addMenu_select_sort").val());
//给上传文档类型上传
    $("#documentType").attr("value",typeStr);
//关闭遮罩层
unlockWindow('addMenu');
    document.getElementById("addMenu").style.display = "none";
document.navi_addNode_form.submit();
return;

}

你可能感兴趣的:(jstree)