JsTree鼠标mouseclick事件和鼠标mouseover事件

 $('#treeDeparts').jstree({
                'plugins': ["types", "state"],
                'core': {
                    "themes": {
                        "responsive": false
                    },
                    'data': function (obj, cb) {
                        console.log("obj:", obj);
                        if (obj && obj.id && obj.id != "#") {
                            if (obj.original.type == 'depart' || obj.original.type == 'company') {
                                $apiRole.ListChildDeparts(obj.id, function (result) {
                                    console.log("jstree:", result);
                                    cb.call(this, result.Data);
                                });
                            }
                        } else {
                            //$apiRole.ListChildDeparts(CompanyId, function (result) {
                            //    cb.call(this, result.Data);

                            //});
                            $apiRole.ListRootDeparts($scope.CompanyId, function (result) {
                                cb.call(this, result.Data);
                            });
                        }
                    }
                },
                "types": {
                    "default": {
                        "icon": "fa fa-folder icon-state-success icon-lg"
                    },
                    "company": {
                        "icon": "fa fa-bank icon-state-success icon-lg"
                    },
                    "depart": {
                        "icon": "fa fa-puzzle-piece icon-state-success icon-lg"
                    }
                },
                'state': {
                    "opened": true,
                },
            }).on('activate_node.jstree', function (e, data) { //点击事件
                //console.log("e", e);
                //console.log("data:", data);
                var node = data.node.original;
                //console.log("text:", node.text);
                if (node.type != "type") {
                    $scope.nodeText = node.text;
                    $scope.CurrentDepartId = node.id;
                    $scope.dataTable.refresh();
                }

            })
            .on('hover_node.jstree', function (event, data) { //鼠标移上事件
                var node = data.node.original;
                $scope.DepartName = node.text;
                $scope.$apply($scope.DepartName);

            })

当点击jstree树的节点时触发activate_node.jstree事件

当鼠标移动到节点上方时触发hover_node.jstree事件,此处的鼠标移上事件触发会获取节点数据,利用Angular将数据与页面进行双向绑定,移动到不同的节点页面显示的数据实时更新变化

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值