Load state and save state

I’m having a tree with dynamic loading.

Here’s my code:

tree = new dhtmlXTreeObject(“treeBox”, “100%”, “100%”, 0);
tree.setImagePath(‘/Content/Images/dhtmlx/csh_dhx_skyblue/’);
tree.enableSmartXMLParsing(true);

tree.loadJSON(“ControllerName/MethodName”);
tree.enableActiveImages(1);

tree.setXMLAutoLoading(
function (id) {
tree.loadJSON(“ControllerName/MethodName?parent=” + id,

                function () {
                    tree.attachEvent("onAllOpenDynamic", function () {
                        tree.attachEvent("onOpenEnd", function () {
                            tree.saveOpenStates();
                        });
                    });
                    tree.loadOpenStates();
                }
            );
        }

);

tree.setXMLAutoLoadingBehaviour(“function”);

The loading and saving of state doesn’t work. What is the problem?

Please ignore the previous post, I fixed it. The solution was to apply the same events on the first loadJson call too.