Topic: Getting Checked nodes from post?

Hi,

I was wondering if it is at all possible to receive all checked nodes in a form POST?

How would that work?  Or how else can I get all checked nodes back to a server side php file?

Thanks
Adriaan

Re: Getting Checked nodes from post?

- Did you try what return print_r($_POST) after submiting form field?

Re: Getting Checked nodes from post?

new Request({
    url: 'check_process.php',
    method: 'post',//or get
    onComplete: function(answer){
        //do something
    }
}).send({data:{checked:yourTree.getChecked()}})

Re: Getting Checked nodes from post?

Thanks moro

Re: Getting Checked nodes from post?

Hi Moro,

I tried your suggestion like this:

function getChecked() {
    console.log(tree.getChecked());
}

But firebug reports the following error:

too much recursion
[Break on this error] var msg = "Error in hook: "+ exc +" fn=\n"+fn+"\n stack=\n";

Please I need a solution really urgently...so any help would be greatly appreciated

Re: Getting Checked nodes from post?

Moro,

I also tried using a hidden input field, and add the node id's to that input field as soon as they are checked, and remove them again as they are unchecked, which should work fine, but...there's always a but wink

The dependant nodes do not fire events when they are indirectly checked, how could I fire events for them, because then I wouldn't need a solution to the problem I posted above...

Thanks again for your help, I really appreciate it.

Re: Getting Checked nodes from post?

Hi Moro,

I found a solution to fire the event when dependant checkboxes are checked and unchecked:

I changed this code:

        var setState=function(node, state){
            if(!node.hasCheckbox) return;
            var oldState=node.state.checked;
            node.state.checked=state;
            if(!node.parentNode || (node.parentNode && node.parentNode.$draw)){
                node.getDOM('checkbox').removeClass('mif-tree-node-'+oldState).addClass('mif-tree-node-'+state);
            }
        };

To this:

        var setState=function(node, state){
            if(!node.hasCheckbox) return;
            var oldState=node.state.checked;
            this.tree.fireEvent(checked=='checked' ? 'check' : 'unCheck', node);
            node.state.checked=state;
            if(!node.parentNode || (node.parentNode && node.parentNode.$draw)){
                node.getDOM('checkbox').removeClass('mif-tree-node-'+oldState).addClass('mif-tree-node-'+state);
            }
        };

Thanks for a great class!!!