jstree utilities$ (document). On (' Dnd_stop.vakata ', function (e, data) { var tree = $ ("#cat_tree"). Jstree (True); var id = data.data.nodes[0]; var Node = tree.get_node (ID); console.log (node);}); Jstree – contextmenu pluginfunction show_tree () { $ (' #cat_tree '). Jstree (' destroy '); var $tree = $ (' #cat_tree ') // listen for event .on (' Changed.jstree ', function (e, data) { var id = data.selected[data.selected.length-1]; $ (' #cat_id '). Val (id); $ (' #show_selected_id '). html (' id: ' + id); }) .on ( ' Rename_node.jstree ', function (e, data) { //console.log ( data.node.id); //console.log (is_numeric(data.node.id)); if (Is_numeric (data.node.id) == false) return; Var parent = data.node.parent; if (parent == ' # ') { parent = 0; } update_item (' Update ', parent, data.node.id, data.text); }) .on (' Delete_node.jstree ', function (e, data) { delete_ Item (data.node.id); }) .on (' Create_node.jstree ', function (E, data) { update_item (' new ', data.node.parent, 0, Data.node.text); $.ajax (' services/cat/get_tree.php ', { type: ' POST ', data: {}, success: function (data, TEXTSTATUS, JQXHR) { &Nbsp; //console.log (data); $ Tree.jstree ({ ' core ': { "multiple" : false, ' data ': data, "Check_callback" : true }, ' plugins ': [' ContextMenu ', ' Sort ", ' state '], contextmenu: {items: context_menu} }); }, eRror: function (Jqxhr, textstatus, errorthrown) { $.msg (' Error: ' + Jqxhr.responsetext); } }); Function context_menu (node) { var tree = $ (' #cat_tree '). Jstree (true); // the default set of all items var items = { "Create": { "Separator_before": false, "Separator_after": false, "label": "Create", " Action ": function (obj) { var $node = tree.create_node (node);  &NBSp; tree.edit ($node); } }, "Rename": { "Separator_before": false, "Separator_after": false, "label": "Rename", "Action": function (obj) { tree.edit (node); } }, "Edit": { "Separator_before": false, "Separator_after": false, "label": "Edit", "Action": function (obj) { //tree.edit (node); } }, "Remove" : { "Separator_before": true, "Separator_after": false, "label": "Remove", "Action": function (obj) { if (Confirm (' are you sure to remove This category? ')) { tree.delete_node (node); } } } }; return items;}
Jstree–contextmenu Plugin