zoukankan      html  css  js  c++  java
  • jstree onselect回调方法,获取选中节点的值 Fred


    应用jstree的onselect事件,获取当前选中的节点的名字,并且赋值给一个input:
    <script type="text/javascript">
    function log(str) {
        $(
    "#log").prepend(str + "<br />");
    }
    $(
    function () {
        $(
    "#demo").tree({
          data  : {
            type  : 
    "json",
            json  : [ 
              { attributes: { id : 
    "pjson4_1" }, data: "Root node 1", children : [
                { attributes: { id : 
    "pjson4_2" }, data: { title : "Custom icon", icon : "../media/images/ok.png" } },
                { attributes: { id : 
    "pjson4_3" }, data: "Child node 2" },
                { attributes: { id : 
    "pjson4_4" }, data: "Some other child node" }
              ]}, 
              { attributes: { id : 
    "pjson4_5" }, data: "Root node 2" } 
            ]
          },
          rules : {
            droppable : [ 
    "tree-drop" ],
            multiple : 
    true,
            deletable : 
    "all",
            draggable : 
    "all"
          },
          callback : {
                    
    onselect    : function (NODE) {    $("#txtSelectedValue").val($(NODE).children("a").text())} 

          }
        });
    });
    </script>
  • 相关阅读:
    java高级语法4:集合
    java高级语法3:异常和注解
    Java高级语法2:Lambda表达式
    VS编译时卡在正在从以下位置加载xxx.dll符号
    mysql中的外键
    localhost和127.0.0.1的区别
    添加依赖项
    代码版本控制——TFS
    优化版冒泡排序
    visual studio vode 汉化
  • 原文地址:https://www.cnblogs.com/Fred_Xu/p/jstree_onselect_callback.html
Copyright © 2011-2022 走看看