jstree:如何获取节点未确定状态的 id

win*_*ell 1 checkbox jquery plugins jstree

我使用 jstree('get_selected',false) 通过复选框插件获取我的 jstree 的选定节点,但结果不包括具有未确定状态的节点。我怎样才能让所有选定的节点都包括未确定的节点。

最新版本的 jstree 不包括方法“get_checked”,为什么?

谢谢。

suo*_*dev 5

jstree 版本 3 确实具有 get_selected 功能,它为您提供所有选中的项目

        var selectedElements = $('#treeidhere').jstree("get_selected", true);
        // Iterate over all the selected items
        $.each(selectedElements, function () {
            alert(this.id);
        });
Run Code Online (Sandbox Code Playgroud)

对于未确定的节点,

        var checked_ids = [];
        $("#treeidhere").find(".jstree-undetermined").each(function (i, element) {
            alert($(element).closest('.jstree-node').attr("id"));
            checked_ids.push($(element).attr("id"));
        });
Run Code Online (Sandbox Code Playgroud)