relysis
relysis

Reputation: 1075

icon change for one node of a jstree

I have created a tree-like structure using jstree and i want to change the icon for only one node at a click of a button, but instead of changing the icon, the icon disappears. The code I managed to create till now:

    function changeIcon()
    {
        $("#li1>a>ins.jstree-icon").css("background-image", "url(image.png)");
    }

The function is called at an onclick() event from a button.

I believed that maybe the path for the image was wrong(the image is in the same folder as the php file that creates the tree), but I tried to change the icons for all items with same 'rel' attribute, and the icons changed. Not sure if this is needed, but to be sure, this is the test I did,and all the items with file attribute changed their icons:

    $("#test").jstree({
           "types" :{ "types" :{
                "file" : { "icon" : { "image" : "image.png" }}
           } },
            "plugins" : [ "themes", "html_data", "dnd", "ui", "types", "crrm" ],

        });

Any ideas?

Upvotes: 1

Views: 2432

Answers (1)

relysis
relysis

Reputation: 1075

Just in case anyone gets the same problem, I finally managed to solve the issue. I had to set the background to transparent, or else it would appear over the image, and that is why nothing appeared. So now the function looks like:

    function changeIcon()
    {
        $("#li1>a>ins.jstree-icon").css("background", "transparent");
        $("#li1>a>ins.jstree-icon").css("background-image", "url(image.png)");
    }   

Upvotes: 2

Related Questions