i am using jstree and am already adding new nodes with the create_node function. But can anyone tell me how to add "li_attr" data while using the create_node function?
Thanks in advance
.jstree('create_node', $(parent_node), eval(new_node_text), position, false, false);
Hope This helps you. You can modify the li_attr property to include any other attributes or values that you need for your use case.
// Define the new node text and its attributes
var new_node_text = {
"text": "New Node",
"li_attr": {
"data-attribute1": "value1",
"data-attribute2": "value2"
}
};
// Create the new node and add it to the parent node
$("#jstree").jstree("create_node", parent_node, new_node_text, "last", function(node) {
// Callback function called after the node has been created
// Here you can perform any additional actions on the new node
});