jsTree plugins 종류가 아래와 같다.
이중 checkbox, contextmenu(오른쪽메뉴), dnd(드레그앤드롭), search(검색) 정도만 테스트 해볼 예정이다.

checkbox
<!DOCTYPE html>
<html lang="ko">
<head>
<!-- jsTree theme -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
</head>
<body>
<div id="plugin_checkbox">
	<ul>
      <li>Root node 1
        <ul>
          <li id="child_node_1">Child node 1</li>
          <li>Child node 2</li>
        </ul>
      </li>
      <li>Root node 2</li>
    </ul>
</div>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<!-- jsTree -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script>
$(function () { 
	$("#plugin_checkbox").jstree({
	    "checkbox" : {
	      "keep_selected_style" : false
	    },
	    "plugins" : [ "checkbox" ]
	  });
});
</script>
</body>
</html>

contextmenu(오른쪽마우스 메뉴)
<!DOCTYPE html>
<html lang="ko">
<head>
<!-- jsTree theme -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
</head>
<body>
<div id="plugin_contextmenu">
	<ul>
      <li>Root node 1
        <ul>
          <li id="child_node_1">Child node 1</li>
          <li>Child node 2</li>
        </ul>
      </li>
      <li>Root node 2</li>
    </ul>
</div>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<!-- jsTree -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script>
$(function () { 
    $("#plugin_contextmenu").jstree({
    "core" : {
    // so that create works
    "check_callback" : true
    },
    "plugins" : [ "contextmenu" ]
    });
	
});
</script>
</body>
</html>

dnd(drag & drop)
<!DOCTYPE html>
<html lang="ko">
<head>
<!-- jsTree theme -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
</head>
<body>
<div id="plugin_dnd">
	<ul>
      <li>Root node 1
        <ul>
          <li id="child_node_1">Child node 1</li>
          <li>Child node 2</li>
        </ul>
      </li>
      <li>Root node 2</li>
    </ul>
</div>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<!-- jsTree -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script>
$(function () { 
  $("#plugin_dnd").jstree({
    "core" : {
      "check_callback" : true
    },
    "plugins" : [ "dnd" ]
  });
});
</script>
</body>
</html>
search
<!DOCTYPE html>
<html lang="ko">
<head>
<!-- jsTree theme -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css" />
</head>
<body>
<input type="text" id="plugins4_q" value="" class="input" style="margin:0em auto 1em auto; display:block; padding:4px; border-radius:4px; border:1px solid silver;">
<div id="plugin_search">
	<ul>
      <li>Root node 1
        <ul>
          <li id="child_node_1">Child node 1</li>
          <li>Child node 2</li>
        </ul>
      </li>
      <li>Root node 2</li>
    </ul>
</div>
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.min.js"></script>
<!-- jsTree -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js"></script>
<script>
$(function () { 
	$("#plugin_search").jstree({
	    "plugins" : [ "search" ]
	  });
	  var to = false;
	  $('#plugins4_q').keyup(function () {
	    if(to) { clearTimeout(to); }
	    to = setTimeout(function () {
	      var v = $('#plugins4_q').val();
	      $('#plugin_search').jstree(true).search(v);
	    }, 250);
	  });
});
</script>
</body>
</html>

'dev > JavaScript' 카테고리의 다른 글
| [jsTree] 함수 정리 (0) | 2021.03.11 | 
|---|---|
| [jsTree] jsTree 사용해보기 (0) | 2021.03.03 | 
| jQuery Code Assist (jQuery 코드 자동완성) (0) | 2017.05.06 | 
| 여러가지 객체사용법 2 (0) | 2017.04.27 | 
| 여러가지 객체사용법 1 (0) | 2017.04.27 |