kukko
kukko

Reputation: 653

JSTree create_node not working

I want to create a new node inside a node when you click on its last children.

I tried the following script, but it always returns false instead of the new node id.

$('#categories').jstree().create_node('#', 'Foo');

This is the same code with a different syntax, but this isn't working either:

$('#categories').jstree().create_node('#', {data:'Foo'});

And these are also the same:

$('#categories').jstree('create_node', '#', {data:'Foo'});
$('#categories').jstree('create_node', '#', 'Foo');

Upvotes: 1

Views: 4504

Answers (1)

Nikolay Ermakov
Nikolay Ermakov

Reputation: 5061

You have to add "check_callback": true to your tree config like below.

Check demo - Fiddle demo.

$("#categories").jstree({
    "core": {
        "data": ...,
        "check_callback": true
    }
});

Upvotes: 8

Related Questions