`
ganjuelovejava
  • 浏览: 94824 次
  • 性别: Icon_minigender_2
  • 来自: 湖南
社区版块
存档分类
最新评论

jstree初始化

阅读更多
<script type="text/javascript">
//对节点初始化
$(function () {
// All those configuration options are documented in the _docs folder
$("#demo")
.jstree({
core : { 
animation : 1    //折叠速度
                   },//点击节点获取子节点
         "core" : { "initially_open" : [ "root2" ] },
         "html_data" : {
         "data" : '<%=htmlSegment%>',
            "ajax" : {
                 "url" : "ajaxFacture.do?libName=<%=libName%>&libId=<%=libId%>&libVersion=<%=libVersion%>", 
                 cache : false,
                 async : true,//动态加载数据
              "data" :  function (n) {
                 return { id : n.attr ? n.attr("id") : 0 };   }   }   },

"themes" : { 

             "theme" : "default", 
             "dots" : false,   //隐藏图标
             "icons" : true
        },
     "plugins" : [ "themes", "html_data","dnd","contextmenu","crrm" ,"checkbox"]

         })//绑定删除事件
.bind("remove.jstree", function (e, data) {
data.rslt.obj.each(function () {

$.ajax({
async : false,
type: 'POST',
url: "NaviUtilServlet.do",
data :
{
"type" : "remove",
"id" : this.id.replace("node_",""),
"libv" : $("#libVersion").val(),
"libid" : $("#libId").val()
},
success : function(falg){
   if(falg == "false"){
      alert("删除失败!");
}}});});
})//绑定修改节点名称事件
.bind("rename.jstree", function (e, data) {
$.ajax({
async : false,
type: 'POST',
url: "NaviUtilServlet.do",
data :
{
"type" : "rename",
"id" : data.rslt.obj.attr("id").replace("node_",""),
"libv" : data.rslt.obj.attr("libv").replace("node_",""),
"libid" : data.rslt.obj.attr("libid").replace("node_",""),
"nodeName" : data.rslt.new_name
},
success : function(falg){
   if(falg == "false"){
      alert("修改名称失败!");
}}});
})//绑定移动节点事件
.bind("move_node.jstree", function (e, data) {
data.rslt.o.each(function () {
         //目标节点
         var targetTopicId = data.rslt.np.attr("id").replace("node_","");
         //下一个兄弟节点
         var nextId = $(this).next("li").attr("id");
         if(nextId == "undefined"){
              nextId = "";
         }
         if(targetTopicId == "demo"){
              targetTopicId = "";
         }
        
       $.ajax({
async : false,
type: 'POST',
url: "NaviUtilServlet.do",
data :
{
"type" : "drag",
"id" : $(this).attr("id").replace("node_",""),
"libv" : $(this).attr("libv"),
"libid" : $(this).attr("libid"),
"nextId" : nextId,
"targetTopicId" : targetTopicId
},
       success : function(falg){
   if(falg == "false"){
      alert("拖动失败!");
}}})});});});
</script>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics