zoukankan      html  css  js  c++  java
  • jstree: 获得根节点,checkbox事件处理

    $.jstree.defaults.core.themes.responsive = true;
    $.jstree.defaults.checkbox.three_state = false;// 如果不禁止,则会自动选择所有父节点。
    $.jstree.defaults.checkbox.tie_selection = false;//如果不禁止,选中checkbox时只触发changed.jstree事件
    
    var tree = $('#tree').jstree(
    {
        'core' : {
            "multiple" : true,
            "themes" : 
                {"stripes" : true},
                'data' : {
                    'url' : function(node) {
                        return appPath + '/app/trainingcar/tree/'
                                + inscode + "/";
                    },
                    'data' : function(node) {
                        return {
                            'carnum' : node.id
                        };
    
                }
            }
        },
        "plugins" : [ "checkbox" ]
    });
    
    tree.on('loaded.jstree', function(e, data) {
        // 加载完树后执行
        $('.jstree-anchor').children().first().remove();// 删除根节点的checkbox
        var rootID = data.instance.get_node(e.target.firstChild.firstChild.lastChild).id;
        console.info("根节点:{}" + rootID);
    });
    
    
    tree.on('changed.jstree', function(e, data) {
        var selectedNode = data.instance.get_node(data.selected[0]);
        console.info('changed.jstree');
        console.info(selectedNode);
    });
    
    tree.on('check_node.jstree', function(data, selected, e) {
        // 选中checkbox时触发
        // selected为选中的节点
        console.info("check_node:");
        console.info(selected);
    });
    
    tree.on('uncheck_node.jstree', function(data, selected) {
        // 勾除checkbox时触发
        console.info("uncheck_node:");
        console.info(selected);
    });

  • 相关阅读:
    python3 urllib 类
    python 金角大王博客园学习地址
    配置文件一mapper.xml
    配置文件一mybatis-config.xml
    配置文件一applicationContext.xml
    类文件路径一classpath
    配置文件一web.xml
    日志框架一logback配置和使用
    SpringBoot + redis实现分布式session共享
    SpringBoot集成Redis 一 分布式锁 与 缓存
  • 原文地址:https://www.cnblogs.com/huiy/p/11988017.html
Copyright © 2011-2022 走看看