2014-01-22 57 views
4

我嘗試添加自定義圖標到'類型'插件的節點,但它不起作用或通過'圖標'字段,但然後我不能從'自動'值更改背景大小。 任何人都可以幫助我,請。jsTree 3中的自定義圖標?

$("#jstree") 
     .on("ready.jstree", function (e, data) { 
      $('div#jstree li > a[rel="disabled"] i.jstree-checkbox').remove(); 
     }) 
     .on("open_node.jstree", function (e, data) { 
      $('div#jstree li > a[rel="disabled"] i.jstree-checkbox').remove(); 
     }) 
     .jstree({ 
     "core": { 
      "data": { "url": "/Home/TreeData" } 
     }, 
     "types": { 
      "boss": { 
       "icon": "/Content/jsTree/boss.png" 
      } 
     }, 
     "plugins": ['checkbox', 'theme', "html_data"] 
    }); 

JSON:

[{"id":null, 
    "text":"Root", 
    "icon":"/Content/jsTree/boss.png", 
    "state":null, 
    "children": 
    [{"id":null, 
     "text":"Leaf A", 
     "icon":null, 
     "state":null, 
     "children":null, 
     "li_attr":{"rel":"boss"}, 
     "a_attr":null}, 
    {"id":null, 
     "text":"Leaf B", 
     "icon":null, 
     "state":null, 
     "children":null, 
     "li_attr":null, 
     "a_attr":{"rel":"boss"}}, 
    {"id":null, 
     "text":"Leaf C", 
     "icon":null, 
     "state":null, 
     "children":null, 
     "li_attr":null, 
     "a_attr":{"rel":"disabled"} 
    }], 
    "li_attr":null, 
    "a_attr":null 
}] 

回答

6

您需要添加的 '類型' 的插件在插件列表:

"plugins": ['checkbox', 'theme', "html_data", "types"] 

您還需要在節點的數據以提供type屬性(而不是使用li_attr):

[{"id":null, 
    "text":"Root", 
    "icon":"/Content/jsTree/boss.png", 
    "state":null, 
    "type":"boss" 
    ... 
+0

所以你需要重複每個具有相同圖標的元素的整個網址?這不可能是答案... –