2014-07-14 39 views
0

我目前有2個jstrees都使用Types插件來定義每個節點的類型。我的問題是,當我從jstree#1中將類型爲「Topic」的節點拖到具有「Folder」類型節點的另一棵樹jstree#2時,它只是給我一個紅色的X.我有用「valid_children」:「Topic」 on jstree#2多棵樹之間的Jstree Valid_children

jstree#1工具箱。用於將某些節點拖入另一個節點。 「Always_copy」

.jstree({ 
    "core": { 
     //Prevent node from being deleted when moved to the design tree 
     "check_callback": function (operation, node, node_parent, node_position, more) { 

     }, 
     "data": { 
      "url": getToolTreeUrl, 
      "data": function (node) { 
       return { 'id': node.id }; 
      } 
     } 
    }, 
    //Enabled the drag and drop plugin with ability to drag and drop between tree 
    "plugins": ["dnd", "unique", "types", "ccrm"], 
    "crrm": { 
     "move": { 
      "check_copy": function() { 
       alert("Check_Copy"); 
      }, 
     }, 
    }, 
    "types": { 
     "#": { 
      "max_children": 1, 
      "max_depth": 2 
     }, 
     "Topic": { 
      "valid_children": "Task" 
     }, 
     "Task": { 
      "valid_children": "Task" 
     }, 
     "Paragraph": { 

     }, 
     "Dictionary_List": { 

     }, 
     "Ordered_List": { 

     }, 
     "Unordered_List": { 

     }, 
     "List_Item": { 

     }, 
     "Picture": { 

     }, 
     "Video": { 

     }, 
     "Table": { 

     }, 
     "Note": { 

     }, 
     "QHSE-Note": { 

     }, 
    }, 
    "dnd": { 
     always_copy: true, 
     is_draggable: function (data) { 
      return data[0].id != 0; //disallow entire toolbox being dragged 
     }, 
    }, 
    rules: { 
     multitree: true, 
     draggable: "all" 
    } 
}); 

}

jstree#2是我的文檔,從工具箱接收節點。

.jstree({ 
    "core": { 
     "check_callback": function (operation, node, node_parent, node_position, more) { 
      var type = node.text; 
      var parentValue = node.parent; 

      if (operation == "move_node") { 
       asyncPost(getObjectLogicCheckUrl); 
      } 
      if (operation == "copy_node") { 
       asyncPost(getObjectLogicCheckUrl); 
      } 
     }, 
     "data": data 
    }, 
    "plugins": ["dnd", "contextmenu", "types"], contextmenu: { items: customMenu }, 
    "crrm": { 
     "move": { 
      "check_copy": function() { 
       alert("Check_Copy"); 
      }, 
     }, 
    }, 
    "types": { 
     "#": { 
      "max_children": 1 
     }, 
     "Topic": { 
      //"valid_children": "Task" 
     }, 
     "Task": { 
      //"valid_children": ["Task", "Paragraph", "Dictionary_List", "Ordered_List", "Unordered_List", "Picture", "Video", "Table", "Note", "QHSE-Note"], 
     }, 
     "Paragraph": { 
      //"valid_children": ["Paragraph", "Dictionary_List", "Ordered_List", "Unordered_List", "Picture", "Video", "Table", "Note", "QHSE-Note"] 
     }, 
     "Dictionary_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "Ordered_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "Unordered_List": { 
      "valid_children": ["List_Item"] 
     }, 
     "List_Item": { 
      "max_children": 0 
     }, 
     "Picture": { 
      "max_children": 0 
     }, 
     "Video": { 
      "max_children": 0 
     }, 
     "Table": { 
      "max_children": 0 
     }, 
     "Note": { 

     }, 
     "QHSE-Note": { 

     }, 
     "Folder": { 
      "valid_children": "Topic" 
     }, 
    }, 
    rules: { 
     multitree: true, 
     draggable: "all", 
    }, 

我想找出一種方法來鎖定哪些節點可以拖動到文檔樹中的哪裏。 IE ..類型爲「Topic」的節點只能接受類型爲「Task」的節點。

如果有人知道如何啓用類型插件在多個樹之間工作,請幫助。

回答

0

我想通了。兩個樹節點都需要應用相同的規則才能工作。

jstree#1

"Topic": { 
     "valid_children": "Task" 
    }, 

jstree#2

"Topic": { 
     "valid_children": "Task" 
    },