Place checkbox in just two items - JSTREE

2

I would like to know how I can make the Child 1 and the Child 2 checkbox to be what I can check and uncheck?

Note: But only these two we .

Code JSFiddle

    
asked by anonymous 14.04.2015 / 23:10

1 answer

2

You can enable the option to use checkbox in the plugin and hide with CSS those that are not descendants of .jstree-children , eg:

HTML

<div id="jstree">
    <ul>
        <li>Folder 1
            <ul>
               <li id="child_1">Child 1</li>
               <li>Child 2</li>
            </ul>
        </li>
        <li>Folder 2</li>
    </ul>
</div>

CSS

ul:not(.jstree-children) > li.jstree-node > a.jstree-anchor > i.jstree-checkbox
{
    display:none;
}

jQuery

$(function () {
    $('#jstree').jstree({
      "checkbox": {
          "keep_selected_style": true
      },
      "plugins": ["checkbox"]
  });
});

See example in JSFiddle

    
15.04.2015 / 01:29