JSTree Add Modify Delete custom nodes

28 Views Asked by At

I'm using jsTree for the first time and I'm having problems with the following code

        $('#jstreeContent').jstree({
            plugins: ["contextmenu"], contextmenu: {
                'select_node': false, items: function ($node) {
                    return {
                        "Create": {
                            "label": "Create a new employee",
                            "action": function (obj) {
                                this.create(obj);
                            }
                        },
                        "Rename": {
                            "label": "Rename an employee",
                            "action": function (obj) {
                                this.rename(obj);
                            }
                        },
                        "Delete": {
                            "label": "Delete an employee",
                            "action": function (obj) {
                                this.remove(obj);
                            }
                        }
                    };
                }
            },
            "core": {
                "animation": 0,
                "check_callback": true,
                "themes": { "stripes": true },
                'data': equipTree
            },
            "types": {
                "#": {
                    "max_children": 1,
                    "max_depth": 2,
                    "valid_children": ["root"]
                },
                "root": {
                    "icon": "/static/3.3.15/assets/images/tree_icon.png",
                    "valid_children": ["default"]
                },
                "default": {
                    "valid_children": ["default", "file"]
                },
                "file": {
                    "icon": "glyphicon glyphicon-file",
                    "valid_children": []
                }
            },
            "plugins": [
                "contextmenu", "dnd", "search",
                "state", "types", "wholerow"
            ]
        });

I'm trying to add custom names with diferent actions, but I'm getting the error: "this.create is not a fuction"

Can someone help? Thanks.

0

There are 0 best solutions below