31

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. :)

jeev
  • 478
  • 10
  • 25
Gazillion
  • 4,822
  • 11
  • 42
  • 59

10 Answers10

25

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.

FabioSorre
  • 310
  • 3
  • 11
  • I can verify that this is a correct and working solution. So if you will put a little png to your root `images` folder then you should use path like `
  • `
  • – NoWar Aug 26 '14 at 11:43
  • 5
    If someone need to add font awesome icon you can just write `
  • `
  • – Nenad Vracar Sep 26 '17 at 19:40