/*
Share with me - only Copy- --done--
Share with me - Not Droppable- --done--
And my tree - Create new folder- --done--
And my tree - Delete new folder- --done--
And my tree - Rename new folder- --done--
And my tree - Operations Restict on type [folders,default]- --done--
And my tree - Save json on any change on tree- --Button--
JavaScript
$(function () {
$('#jstreeSave').click(function () {
var v = $("#mydocs-tree").jstree(true).get_json('#', {
'flat': true
});
var mytext = JSON.stringify(v);
console.log(v);
var ids = [];
for (var i in v) {
if (typeof (v[i].li_attr['data-id']) != "undefined") {
ids.push(v[i].li_attr['data-id']);
}
};
var uniqueIds = ids.filter(function (elem, pos) {
return ids.indexOf(elem) == pos;
});
console.log(uniqueIds);
})
$('#jstreeFolderCreate').click(function () {
var ref = $('#mydocs-tree').jstree(true),
sel = ref.get_selected();
if (!sel.length) {
return false;
}
sel = sel[0];
sel = ref.create_node(sel, {
"type": "file"
});
if (sel) {
ref.edit(sel);
}
});
$('#jstreeFolderRename').click(function () {
var ref = $('#mydocs-tree').jstree(true),
sel = ref.get_selected();
if (!sel.length) {
return false;
}
sel = sel[0];
ref.edit(sel);
});
$('#jstreeFolderDelete').click(function () {
var ref = $('#mydocs-tree').jstree(true),
sel = ref.get_selected();
if (!sel.length || !ref.get_node(sel).children.length == 0) {
return false;
}
ref.delete_node(sel);
});
$('#incoming-tree')
.jstree({
"core": {
"check_callback": function (o, n, p, pos, more) {
if (more && more.dnd && more.is_multi) {
return false;
}
return true;
}
},
"types": {
"template": {
"valid_children": [],
"icon":...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.