BJUI设置权限勾选子级自动选择父级

<script type="text/javascript">
    function checkHome($obj,$pid)
    {
        var checked=$obj.checked;
        if(checked)
        {
            $('[pid='+$pid+']').attr('checked',true);
        }
        else
        {
            $('[pid='+$pid+']').attr('checked',false);
        }
    }
    function check($obj,$id,$pid)
    {
        var checked=$obj.checked;
        if(checked)
        {
            $('.check'+$id).attr('checked',true);
        }
        else
        {
            $('.check'+$id).attr('checked',false);
        }
        home($pid);
    }
    function home($pid)
    {
        var homeCheckedLength = $('[pid='+$pid+']:checked').length;
        if(homeCheckedLength>0)
        {
            $('#'+$pid).attr('checked',true);
        }
        else
        {
            $('#'+$pid).attr('checked',false);
        }
    }
    function checkChild($id,$pid)
    {
        var checkedLength=$('.check'+$id+':checked').length;
        if(checkedLength>0)
        {
            $('#check'+$id).attr('checked',true);
        }
        else
        {
            $('#check'+$id).attr('checked',false);
        }
        home($pid);
    }

script>

<div class="bjui-pageContent">
    <form action="{:U('edit')}" class="pageForm" data-toggle="validate">
        <volist name="tree" id="vo1">
            <div style="margin: 0px 0px 40px 0px;">
                <h4 style="font-weight: bold;">
                    <input type="checkbox"  name="ids"
                           
                    id="{$vo1.id}" οnclick="checkHome(this,{$vo1.id})"
                    >
                    {$vo1.title}
                h4>

                    <div>
                        <volist name="vo1['_data']" id="vo2">
                            <fieldset style="margin-top: 16px;">

                                <legend>
                                    <input type="checkbox"  name="ids"
                                           pid="{$vo1.id}"
                                           id="check{$vo2.id}"
                                           οnclick="check(this,{$vo2.id},{$vo1.id})"
                                    >
                                    {$vo2.title}
                                legend>

                                <volist name="vo2['_data']" id="vo3">

                                    <label for="" style="padding: 0px 5px 0px 50px;">
                                        <input type="checkbox"  name="ids"
                                               pid="{$vo1.id}"
                                               class="check{$vo2.id}"
                                               οnclick="checkChild({$vo2.id},{$vo1.id})"
                                        >
                                        {$vo3.title}
                                    label>

                                volist>

                            fieldset>
                        volist>
                    div>
            div>
        volist>
    form>
div>

你可能感兴趣的:(BJUI设置权限勾选子级自动选择父级)