English 中文(简体)
JsTree:使用“类型”粉碎机改变“开放式”icon
原标题:JsTree: changing the "open" icon for folders using the "types" plugin

很容易地说明,使用“类型”粉饰物的封闭式粘合器应当是什么。 但是,这些类型也可用来说明 open<>/strong> 夹应当看什么,或者我只能与安保部接洽(如下文)?

li.jstree-open > a .jstree-icon 
{
    background:url("folder_open.png") 0px 0px no-repeat !important;
} 
问题回答

A possible solution is to have two types - one for an open folder, and one for a closed folder. Changing the node type is easy.

From another answer of mine:

<div id="jstree_menu"></div>
<script>
/* Load menu tree data */
$( #jstree_menu ).jstree(
    {
         core  : {
             data  : {
                 url  :  /jstree-menu-data/index.html ,
            }
        },
         plugins  : [ "types" ],
         types  : {
             default  : {
                 icon  :  fa fa-angle-right fa-fw 
            },
             f-open  : {
                 icon  :  fa fa-folder-open fa-fw 
            },
             f-closed  : {
                 icon  :  fa fa-folder fa-fw 
            }
        }
    }
);

/* Toggle between folder open and folder closed */
$("#jstree_menu").on( open_node.jstree , function (event, data) {
    data.instance.set_type(data.node, f-open );
});
$("#jstree_menu").on( close_node.jstree , function (event, data) {
    data.instance.set_type(data.node, f-closed );
});
</script>

@Seventh 内容:

Your code in the question itself is the answer.It works pretty fine. For open node use

li.jstree-open > a .jstree-icon { background:url("/images/favorites.png") 0px 0px no-repeat !important; }

封闭的节点使用

li.jstree-closed > a .jstree-icon { background:url("/images/favorites.png") 0px 0px no-repeat !important; }

卡车

如果你想使用 j子和boot子,我会这样做。

[Note: I use glyphicon-folder-open bootstrap icon for folder open and glyphicon-folder-close bootstrap icon for folder close.]

// bind customize icon change function in jsTree open_node event. 
$( #your-jstree ).on( open_node.jstree , function(e, data){
   $( #  + data.node.id).find( i.jstree-icon.jstree-themeicon ).first()
        .removeClass( glyphicon-folder-close ).addClass( glyphicon-folder-open );
});

// bind customize icon change function in jsTree close_node event. 
$( #your-jstree ).on( close_node.jstree , function(e, data){
   $( #  + data.node.id).find( i.jstree-icon.jstree-themeicon ).first()
        .removeClass( glyphicon-folder-open ).addClass( glyphicon-folder-close );
});

或如果你使用真菌:

// bind customize icon change function in jsTree open_node event. 
$( #jstree ).on( open_node.jstree , function(e, data){
    var icon = $( #  + data.node.id).find( i.jstree-icon.jstree-themeicon ).first();
    icon.removeClass( fa-folder ).addClass( fa-folder-open );
});

// bind customize icon change function in jsTree close_node event. 
$( #jstree ).on( close_node.jstree , function(e, data){
    var icon = $( #  + data.node.id).find( i.jstree-icon.jstree-themeicon ).first();
    icon.removeClass( fa-folder-open ).addClass( fa-folder );
});

象你们需要使用手套

li.jstree-open[rel=TYPE]{  background:url("openimage.gif") 0px 0px no-repeat !important; }
li.jstree-closed[rel=TYPE]{  background:url("closedimage.gif") 0px 0px no-repeat !important; }
li.jstree-leaf[rel=TYPE]{  background:url("leafimage.gif") 0px 0px no-repeat !important; }

http://groups.google.com/group/jstree/browse_thread/thread/94d4867cc8048b6e?pli=3”rel=“nofollow” jsTree Forum

如今,有一个称为“set”的功能(见API),允许你从路面或班子上设定离心。

$.jstree.reference( #jstree ).set_icon(node, "/assets/contextMenu_icons/folderOpened.png")




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.