Place checkbox on only two items - JSTREE

Asked

Viewed 116 times

2

I would like to know how I do so that the us Child 1 and the Child 2 be of the checkbox type where I can check and uncheck?

Note: but only these two us.

Code Jsfiddle

1 answer

2


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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.