How to create a new node dynamically?

103 views
Skip to first unread message

Deepu Thekkethil

unread,
Sep 3, 2015, 6:50:47 PM9/3/15
to jsTree
I am trying to create a child node in the after_open event like this:

$('#divTree').on('after_open.jstree', function (e, data) {
console.log(e, data);
var msid = data.node.data;
$('#divTree').jstree("create_node", data.node, 'inside', { state: "open",text:'Sample' }, false, false);
                       
})

But this doesnt work. Can you please suggest the correct way?

Ivan Bozhanov

unread,
Sep 3, 2015, 7:08:57 PM9/3/15
to jsTree
You probably have not set core.check_callback to true, so any modifications to the structure will not work. Once you allow the modifications you will be able to create the node.
Keep in mind "state" : "open" will do nothing - state should be an object, not a string. Besides - you can not have a leaf node marked as opened.

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages