How to change icon in jstree?

Gazillion picture Gazillion · Aug 23, 2011 · Viewed 81.7k times · Source

I have the following code:

$('.wpFolders.co_files').bind('select_node.jstree', function (event, data) {
            getFileById(data.args[0].hash.replace('#', ''));
        }).jstree({
            'plugins' : ['html_data','themes','ui','types'],
            'ui' : {
                'select_limit' : 1
            },
            'core' : {
                'animation' : 0
            },
            'types': {
                'default' : {
                    'icon' : {
                        'image' : '/admin/views/images/file.png'
                    }
                }
            }
        });

I have a basic unordered list I would like to have displayed as a list of files. I'm trying to use the "types" to change the icon but I can't for the life of me figure out how to do it. I checked their docs link and even when using almost identical code nothing seems to happen.

From my understanding of the code above the default type of my tree should have the icon I specified but nothing happens, all I get is the default folder icon.

Any ideas? Sorry if the question seems basic but I find the documentation hard to follow when trying to do basic things. :)

Answer

FabioSorre picture FabioSorre · Mar 10, 2014

After an headache... I found a solution.


    <li data-jstree='{"icon":"path/file.png"}'></li>

I suggest to don't modify the css code.

PS The "types" plug-in is not necessary.