Bootstrap-treeview not setting state with "checkNode" method

1.3k views Asked by At

I'm trying to update the parents and children checked inputs using bootstrap-treeview, but when I use the method "checkNode", the state of the node doesn't change at all.

var trucks = $('#trucks').treeview({
    level: 3,
    showCheckbox: true,
    selectable: false,
    highlightSelected: false,
    data: getTree()
}).on('nodeChecked', function (event, node){
    var childrenNodes = __getChildren(node);
    childrenNodes.forEach(function(n){
        $(trucks).treeview('checkNode', [ n.nodeId, { silent: true } ]);
        console.log(n.state.checked);
    });
});

function __getChildren(node) {
    if (node.nodes === undefined) return [];
    var childrenNodes = node.nodes;
    node.nodes.forEach(function(n) {
        childrenNodes = childrenNodes.concat(__getChildren(n));
    });
    return childrenNodes; 
}

The input is checked normally, but console output says the state is "false"

Anyone have an a idea of what I'm doing wrong?

0

There are 0 answers