jstree Example - Simple

HTML

<script src="http://static.jstree.com/3.0.0-beta3/assets/dist/jstree.min.js"></script>
<link rel="stylesheet" href="http://static.jstree.com/3.0.0-beta3/assets/dist/themes/default/style.min.css">
<script src="https://code.angularjs.org/1.0.3/angular.min.js"></script>
<div id="jstree">
  </div>
<button id="sam">create node</button>

JavaScript

$(function () {
    var data = [
       { "id" : "ajson1", "parent" : "#", "text" : "Simple root node" },
       { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" },
       { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" },
       { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" },
    ];
   $("#jstree").jstree({
     "core" : {
       // so that create works
       "check_callback" : true,
        
        "data": data
     },
    "plugins" : [ "contextmenu",  "dnd"],
        
        "contextmenu":{         
                        "items": {
                            "create": {
                                "label": "Add",
                                "action": function (obj) {
                                    console.log("sunil madaan");
                                    console.log(obj);
                                    $('#jstree').jstree().create_node(['null' ,  { "id" : "ajson5", "text" : "newly added" }, "last", function(){
    alert("done");
 },true
]); 
},
                            }
                        }
        }
        
  }).on('create_node.jstree', function(e, data) {
    console.log('saved');
});
$("#sam").on("click",function() {
    alert("dsfas");
     $('#jstree').jstree().create_node(['null' ,  { "id" : "ajson5", "text" : "newly added" }, "last", function(){
    alert("done");
 },true
]);
});
});