jquery - jstree : how to undelete / restore a node -
i using jstree in application contextmenu plugin.
when deleting node, have ajax request performs operation on database.
i'd delete node view if ajax returns operation = true parameter.
how can undelete jstree node has been deleted following code :
function (data) { var inst = $.jstree.reference(data.reference), obj = inst.get_node(data.reference); if(inst.is_selected(obj)) { inst.delete_node(inst.get_selected()); } else { inst.delete_node(obj); } }
i delete node tree when call successful. doesn't make sense delete node first, make call , if fails try re-add node. here example delete node if ajax call success:
var node = $('#tree').jstree('get_selected'); $.ajax({ url: link, type: 'get', data: { id: node.attr('id') }, async: false, success: function (data, text) { $('#tree').jstree('delete_node', node); }, error: function (request, status, error) { } });
ps. current selected node
Comments
Post a Comment