Home > Web Front-end > JS Tutorial > body text

When Jstree selects the parent node, disable child nodes are also selected

php中世界最好的语言
Release: 2018-04-13 14:09:33
Original
2372 people have browsed it

This time I will bring you JsWhen tree selects the parent node, the disabled child node is also selected, and solves the problem that when Jstree selects the parent node, the disabled child node is also selected.NotesWhat are they? The following is a practical case. Let’s take a look.

Problem Description:

Recently I encountered a problem using jstree. When the parent node is selected, the disabled child nodes will also be selected as follows

solution:

1. Upgrade jstree to the latest version, v3.3.4 and above.

2. Modify the checkbox plug-in configuration and set cascade_to_disabled to false (Note: the configuration script needs to be placed after jstree.min.js)

<script src="./../../dist/jstree.min.js"></script>
<script>
$.jstree.defaults.checkbox = {
      visible: true,
      three_state: true,
      whole_node: true,
      keep_selected_style: true,
      cascade: '',
      tie_selection: true,
      /**
      * This setting controls if cascading down affects disabled checkboxes
      * @name $.jstree.defaults.checkbox.cascade_to_disabled
      * @plugin checkbox
      */
      cascade_to_disabled : false,
      cascade_to_hidden : true
};
 
 
$('#data').jstree({
    'core' : {
      'data' : [
        { "text" : "Root node", "children" : [
            { "text" : "Child node 1", "state": { "disabled": true } },
            { "text" : "Child node 2" },
            { "text" : "Child node 3" },
            { "text" : "Child node 4" },
            { "text" : "Child node 5" },
            { "text" : "Child node 6" }
        ]}
      ]
    }
    ,"plugins" : [ "checkbox" ]
  });
</script>
Copy after login

I believe you have mastered the method after reading the case in this article, please come for more exciting information Pay attention to other related articles on php Chinese website!

Recommended reading:

Detailed explanation of the steps for using custom paginator in Swiper

How to use mint- in vue.js ui carousel component

The above is the detailed content of When Jstree selects the parent node, disable child nodes are also selected. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template