사용자가 파일이나 폴더를 만들도록하고 있습니다. 그들이 바로 메뉴를 클릭 그래서 상황에 맞는 메뉴가 표시됩니다 : 만들 => 파일이 부분이 작동jstree contextmenu 파일/폴더 만들기 기능
이 문제는 다음 상황에 맞는 메뉴의 각에 부착 된 기능에있다 폴더에 있습니다. 현재 '파일'또는 '폴더'를 클릭하면 전화 : this.create(obj);
유형을 어떻게 지정합니까? 나는 obj.attr("rel","type","folder")
을 시도했지만, 나는 obj.rslt.rel
과 많은 다른 것들을 시도했지만 어둠 속에서 단지 촬영하고있다. 나는 문서를 읽었지만, 레이아웃은 좋지만 객체의 속성을 설명 할 때는 쓸모가 없다.
다음은 컨텍스트 메뉴, 유형 플러그 인 및 작성 노드의 바인드에 대한 코드입니다.
fma_jstree = $("#archive")
.bind("before.jstree", function (e, data) {
$("#alog").append(data.func + "<br />");
})
.jstree({
// List of active plugins
"plugins" : [
"themes","json_data","ui","crrm","cookies","dnd","search","types","hotkeys","contextmenu"
//"themes","json_data","ui","crrm","cookies","dnd","search","types","contextmenu"
],
"contextmenu" : {
items : { // Could be a function that should return an object like this one
"create" : {
"separator_before" : false,
"separator_after" : true,
"label" : "Create",
"action" : false,
"submenu" :{
"create_file" : {
"seperator_before" : false,
"seperator_after" : false,
"label" : "File",
action : function (obj) {
this.create(obj);
}
},
"create_folder" : {
"seperator_before" : false,
"seperator_after" : false,
"label" : "Folder",
action : function (obj) { this.create(obj); }
}
}
}
}
},
// Using types - most of the time this is an overkill
// read the docs carefully to decide whether you need types
"types" : {
// I set both options to -2, as I do not need depth and children count checking
// Those two checks may slow jstree a lot, so use only when needed
"max_depth" : -2,
"max_children" : -2,
// I want only `drive` nodes to be root nodes
// This will prevent moving or creating any other type as a root node
"valid_children" : [ "drive" ],
"types" : {
// The default type
"default" : {
// I want this type to have no children (so only leaf nodes)
// In my case - those are files
"valid_children" : "none",
// If we specify an icon for the default type it WILL OVERRIDE the theme icons
"icon" : {
"image" : icon_url + "/file.png"
}
},
// The `folder` type
"folder" : {
// can have files and other folders inside of it, but NOT `drive` nodes
"valid_children" : [ "default", "folder" ],
"icon" : {
"image" : icon_url + "/folder.png"
}
},
// The `drive` nodes
"drive" : {
// can have files and folders inside, but NOT other `drive` nodes
"valid_children" : [ "default", "folder" ],
"icon" : {
"image" : icon_url + "/root.png"
},
// those prevent the functions with the same name to be used on `drive` nodes
// internally the `before` event is used
"start_drag" : false,
"move_node" : false,
"delete_node" : false,
"remove" : false
}
}
},
.bind("create.jstree", function (e, data) {
//if creating a root node
if(!$(data.rslt.parent).attr("id")) var id = 1;
//else get parent
else var id = data.rslt.parent.attr("id").replace("node_","");
$.post(
ajaxurl,
{
"action" : "fma_create_node",
"operation" : "create_node",
"id" : id,
"position" : data.rslt.position,
"title" : data.rslt.name,
"type" : data.rslt.obj.attr("rel")
},
function (r) {
if(r.status) {
$(data.rslt.obj).attr("id", "node_" + r.id);
}
else {
$.jstree.rollback(data.rlbk);
}
},
'json'
);
})
어떤 도움을 잘 이해할 수있을 것이다) 관련, Daithi
@DanielMendel 우리는 폴더의 insted 태그를 만들 수 있습니다. 태그를 만들 수 있습니까? –