zoukankan      html  css  js  c++  java
  • jqtree使用说明

    JqTree is a jQuery widget for displaying a tree structure in html 
    It supports json data, loading via ajax and drag-and-drop.

    Download jqTree

     1 //使用js的严格模式
     2 'use strict';
     3 
     4 var $tree = $('#menutree');
     5 $(document).ready(function () {
     6     getSingle("/oa/api/menu/", function (data) {
     7         data = JSON.parse(data);
     8         console.log(data);
     9         $tree.tree({
    10             //rtl: true,//可以使用rtl选项从右到左显示树。
    11             //buttonLeft: false,//将切换按钮,放到右侧
    12     //         onDragMove: function () {
    13     //             console.log("tuozdaew")   //将菜单拖到树外触发的函数
    14     //         },
    15     // onDragStop: function () {
    16     //                     console.log("11111111111")  //拖动菜单 松开鼠标后触发的函数
    17     //
    18     // },
    19             data: data,
    20             autoOpen: 0,//true  打开全部节点  设置为0以打开第一级节点。
    21             dragAndDrop: true, //选项设置为true来添加拖放支持。现在,您可以将树节点拖动到另一个位置。
    22             saveState: true,//如果将选项saveState设置为true,则jqtree会在页面重新加载后记住树的状态。
    23             onCreateLi: function (node, $li) {
    24                 $li.find('.jqtree-element').append(
    25                     '<a href="#node-' + node.id + '" class="edit" data-node-id="' + node.id + '">' +
    26                     '<i class="fa fa-pencil-square-o"></i>编辑</a>'
    27                 );
    28             },
    29             closedIcon: $('<i class="fa fa-arrow-circle-right"></i>'),
    30             openedIcon: $('<i class="fa fa-arrow-circle-down"></i>')
    31         });
    32     });
    33 /*
    34     $tree.on('tree.click', function (e) {
    35         // Disable single selection
    36         e.preventDefault();
    37         var selected_node = e.node;
    38         console.log(selected_node);
    39         if (selected_node.id === undefined) {
    40             console.warn('警告,每个菜单条目都必须有一个唯一的ID!');
    41         }
    42 
    43         if ($tree.tree('isNodeSelected', selected_node)) {
    44             $tree.tree('removeFromSelection', selected_node);//取消选择
    45 
    46         } else {
    47             $tree.tree('addToSelection', selected_node);//点击选中
    48 
    49 
    50         }
    51     });
    52 */
    53 // 绑定编辑事件
    54     $tree.on('click', '.jqtree_common div a.edit', function (e) {
    55         // Get the id from the 'node-id' data property
    56         var node_id = $(e.target).data('node-id');
    57         console.log(node_id);
    58         // Get the node from the tree
    59         var node = $tree.tree('getNodeById', node_id);
    60         console.log(node);
    61 
    62         if (node) {
    63             // Display the node name
    64             alert(node.name);
    65         }
    66     })
    67 
    68 
    69 });
  • 相关阅读:
    如何解决aws解绑银行卡问题?
    如何解决macbook pro摄像头不工作的问题
    Window安装AutoCAD
    Mac应用程序无法打开,提示不明开发者或文件损坏的处理方法
    Android硬件抽象层(HAL)深入剖析(三)【转】
    Android硬件抽象层(HAL)深入剖析(二)【转】
    Android硬件抽象层(HAL)深入剖析(一)【转】
    Glide的用法
    Gradle-5.3:依赖-管理依赖的版本(传递(transitive)排除(exclude)强制(force)动态版本(+))
    Android 7.0 FileProvider 使用说明
  • 原文地址:https://www.cnblogs.com/Mengchangxin/p/11949240.html
Copyright © 2011-2022 走看看