Trying to get a list of checked items on change_state in jstree

。_饼干妹妹 提交于 2019-12-01 10:34:13

In order to get the checked nodes' JSON you should be using get_checked and not get_selected. Try this:

    var checked = $("#colors").jstree("get_checked",null,true);
    var checked_json = [];
    $(checked).each(function (i,node) {
        var id = $(node).attr("id");
        var text = $(node).attr("text");
        var node_json = { 
            "id" : id, 
            "text" : text 
        };
        checked_json.push(node_json);
    });

After that checked_json will contain an array of of id+text objects which you could send to the server.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!