最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to add a file icon using jstree? - Stack Overflow

programmeradmin0浏览0评论

I have the following code below and need to add a file.png icon to the jstree file structure when clicking on the add_file ($("#treeFile").jstree("create"));

  $("#treeFile").jstree({
                "plugins" : ["themes","html_data","ui","crrm","types"],
                "types" : {
                        "max_depth" : -2,
                        "max_children" : -2,
                        "valid_children" : [ "drive" ],
                        "types" : {
                                "default" : {
                                        "valid_children" : "none",
                                        "icon" : { "image" : "/tree/_demo/file.png"}
                                                         }
                              }
                      }   
                })
                    .bind("select_node.jstree", function (event, data) {

    });

$("#treeMenu li").click(function()
{
    if($(this).text() == "add_file")
    {
        $("#treeFile").jstree("create");

    }else if($(this).text() == "add_folder")
    {
        $("#treeFile").jstree("create");

    }else if($(this).text() == "rename")
    {
        $("#treeFile").jstree("rename");

            }else if($(this).text() == "remove")
    {
        $("#rootNode").jstree("remove");
    }else
    {}

I have the following code below and need to add a file.png icon to the jstree file structure when clicking on the add_file ($("#treeFile").jstree("create"));

  $("#treeFile").jstree({
                "plugins" : ["themes","html_data","ui","crrm","types"],
                "types" : {
                        "max_depth" : -2,
                        "max_children" : -2,
                        "valid_children" : [ "drive" ],
                        "types" : {
                                "default" : {
                                        "valid_children" : "none",
                                        "icon" : { "image" : "/tree/_demo/file.png"}
                                                         }
                              }
                      }   
                })
                    .bind("select_node.jstree", function (event, data) {

    });

$("#treeMenu li").click(function()
{
    if($(this).text() == "add_file")
    {
        $("#treeFile").jstree("create");

    }else if($(this).text() == "add_folder")
    {
        $("#treeFile").jstree("create");

    }else if($(this).text() == "rename")
    {
        $("#treeFile").jstree("rename");

            }else if($(this).text() == "remove")
    {
        $("#rootNode").jstree("remove");
    }else
    {}
Share Improve this question edited Oct 22, 2012 at 19:08 Fran Verona 5,4766 gold badges48 silver badges87 bronze badges asked Oct 22, 2012 at 15:55 Joseph RooseveltJoseph Roosevelt 311 silver badge3 bronze badges 1
  • And? Could you provide working jsfiddle? – Radek Commented Oct 23, 2012 at 4:26
Add a ment  | 

2 Answers 2

Reset to default 8

add 'icon': 'jstree-file' property to node

The syntax to the jstree method add the type attribute to display a file icon is this:

$("#treeFile").jstree("create", null, "inside", { attr : { "rel" : "file"}});

And the problem code change "default" to "file"

发布评论

评论列表(0)

  1. 暂无评论