jstree v1.0
我刚刚对复选框示例进行了修改:http: //www.jstree.com/documentation/checkbox
我的目标:在检查任何节点时,我希望检查所有父节点(默认行为不行,因为这是部分选择的东西,对我不利)
根据提示和文档,我扩展了原始示例,但我发现该check_node方法不起作用。我没有注意到任何影响。
欢迎任何提示或建议。
<div id="demo1" class="demo">
    <ul>
        <li id="phtml_1">
            <a href="#">Root node 1</a>
            <ul>
                <li id="phtml_2" >
                    <a href="#">Child node 1</a>
                </li>
                <li id="phtml_3">
                    <a href="#">A Child node 2</a>
                </li>
            </ul>
        </li>
        <li id="phtml_4">
            <a href="#">Root node 2</a>
        </li>
        <li id="phtml_5">
            <a href="#">Root node 1</a>
            <ul>
                <li id="phtml_51">
                    <a href="#">Child node 1</a>
                </li>
                <li id="phtml_52">
                    <a href="#">A Child node 2</a>
                </li>
            </ul>
        </li>
        <li id="phtml_6">
            <a href="#">Root node 1</a>
            <ul>
                <li id="phtml_61">
                    <a href="#">Child node 1</a>
                </li>
                <li id="phtml_62">
                    <a href="#">A Child node 2</a>
                </li>
            </ul>
        </li>
    </ul>
</div>
<script type="text/javascript" class="source">
$(function () {
    var x = $("#demo1");
    $(x).jstree({
        "checkbox" :{
            real_checkboxes:false,
            override_ui:true,
            two_state:false,    
        },
        "plugins" : [ "themes", "html_data", "checkbox", "ui" ]
    }).bind('check_node.jstree', function (e, data) { 
        console.log('check_node.jstree ----------------------------------------------');
        console.log(e);
        var all_selected = $(x).jstree('get_checked')
        console.log('all_selected='+all_selected);
        for(var i=0;i<all_selected.length;i++){
            var paths = $(x).jstree('get_path', all_selected[i], true);
            console.log('  paths='+paths);
            for(var j=0; j< paths.length;j++){
                console.log('    checking node (not working)='+paths[j]);
                $(x).jstree('check_node',paths[j]);
            }
        }
    });
    console.log('programaticcaly checking last parent node (not working)')
    //$(x).jstree('check_node',$('li#phtml_6'));
    $.jstree._reference("#demo1").check_node('li#phtml_6');
});
</script>