【问题标题】:Jstree, get_checked, pass value to div onselect eventJstree,get_checked,传值给 div onselect 事件
【发布时间】:2012-09-20 10:18:05
【问题描述】:

我正在使用带有 Jstree 的 MVC c# asp.net 4.0 项目,但我有一个小问题,我有一个填充了 JSON 数组的 jstree。

我的问题是,当在我的视图中选中一个 div 时,我需要捕捉 jstree 中复选框的值。

【问题讨论】:

    标签: asp.net-mvc json checkbox jstree


    【解决方案1】:

    好的,我终于得到了这个工作这是我希望它帮助某人的解决方案:)

    首先你必须绑定:

        .bind('check_node.jstree', function (e, data) {
            $("#listSelectedActives").html(BuildList());
        })
       .bind('uncheck_node.jstree', function (e, data) {
           $("#listSelectedActives").html(BuildList());
    

    然后使用这个函数:

    function BuildList() {
        var checked = $("#demoTree").jstree("get_checked", null, true);
        var output = "";
    
        $(checked).each(function (i, node) {
            var id = $(node).attr("ID");
            var text = $(node).attr("NodeText");
    
    
            output += "<p>ID: " + id + " TEXT: " + text + "</p>";
        })
    
        return output;
    }
    

    如果这太令人困惑,请告诉我:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多