2

I'm trying to use jstree.

Actually I'm using the example: PHP & mySQL demo + event order that you can find on a webpage: http://www.jstree.com/demo

I need to create a new type in the tree structure, therefore I added the following lines of code in the lines 059 (on the example that you can see in a quoted link)

 "mytype" : { "valid_children" : "none", "icon" : { "image" :
 "./mytype.png" } },

Then in the code menu for button I also added this in the mmenu input click function:

case "add_mynewtype":
    $("#demo").jstree("create", null, "last", { "attr" : { "rel" : "mytype" } });
    break; 

Obviously I also connected a new input button like this:

<input type="button" id="add_mynewtype" value="Create new type" style="display:block; float:left;"/>

But this doesn't work properly....

Anyone can help me? Thank you so much, any hint are really fully appreciated

Danilo
  • 2,016
  • 4
  • 24
  • 49

1 Answers1

2

I found a solution to my question.

It's necessary modify also the declaration of folder like the follow:

"folder" : {
            "valid_children" : [ "default", "folder", "mytype" ],
            "icon" : {"image" : "./folder.png" }
        },

or:

"folder" : {
            "valid_children" : [ "all" ],
            "icon" : {"image" : "./folder.png" }
        },
Danilo
  • 2,016
  • 4
  • 24
  • 49