mercredi 26 octobre 2016

jquery checkbox in treeview with bonsai

I have this js example:

    goo.gl/HBsQmr

Where I have created a tree list with some checkboxes:

    <!DOCTYPE html>
<html lang="en">
<head>
    <!--script src="js/lib/jquery.min.js"></script-->
    <script src="js/lib/jquery3-1.js"></script>
    <script src="js/lib/jquery.bonsai.js"></script>
    <script src="js/lib/jquery.qubit.js"></script>
    <link rel="stylesheet" href="css/jquery.bonsai.css" type="text/css">

    <script>
    $(document).ready(function () {
        $('#checkboxes').qubit();

        $('#checkboxes').bonsai({
            expandAll: true,
            checkboxes: true, // depends on jquery.qubit plugin
            handleDuplicateCheckboxes: true, // optional
            createInputs: 'checkbox'
        });

    });
    </script>


</head>

<body>

    <ol id='checkboxes' data-name='foo'>
        <li class='expanded' data-value='0'>All
            <ol>
                <li data-name='baz2s' data-value='1' data-id='1'>Environment
                    <ol>
                        <li data-name='baz' data-value='4' data-checked='1'>Waste Collect. and treat.</li>
                        <li data-name='baz1' data-value='5' data-checked='1'>Photovoltaic sys</li>
                        <li data-name='baz2' data-value='6' data-checked='1'>Others</li>
                    </ol>   
                </li>
            </ol>
        </li>
    </ol>



</body>
</html>

The problem is that if I click on Environment checkbox, the parent checkbox are not checked.

If all parent are checked, also Environment checbox is checked and if I uncheck it, parents are also unchecked.

Checking Environments checbox nothing happens.

What I am doing wrong?

Thank you




Aucun commentaire:

Enregistrer un commentaire