Hi,
and thanks to Evan and
mindplay.dk for the tips. I finally got it, and
solved the problem:
I've copied my menutree code from one of the examples, and there, the
mootree variable was defined in the window.load event. Since that's
okay when you initialize the tree only ones, it (of course) causes
problems when reloading the tree by firing the load event, as I did:
Every time the load event is fired, the menutree CONSTRUCTOR is
called, generating another instance of my menutree variable.
So, I've rewritten my code, and now, I define the variable menutree,
and call the menutree.root.load somewhere else in the load event
handler.
That's working perfectly well, so, here's the code if someone can use
it:
var js_navigation = {
menutree : new MooTreeControl({
div: 'navigation',
mode: 'files',
grid: true,
theme: 'mootree2/mootree.gif',
//other stuff like select handlers, etc.
},{
text: 'Menu',
open: true
}),
};
js_navigation.menutree.root.clear();
js_navigation.menutree.root.load('functions/loadmenu.php?
action=loadtree');
One word to mootree's div-handler: Normally, I load all JS functions
by including them in the HTML header - that will not work if you
define your tree like I did, because the div for the tree (in my code,
"navigation") is not defined in the header, so, Mootree cannont adopt
it. So, it's better to include the JS at the bottom of the body, where
all divs are defined.
Also took me a few minutes to figure this out...
Thanks again to the list,
Harald
> > told me about this specialMooTreegroup, so, I re-post it here in the
> > hope that someone can help.
> > I'd like to use MooTree2 for my project (based on MooTools 1.2b2), and
> > it's
> > running quite nice, except of one problem I can't figure out:
> > My tree is dynamically generated, e.g., when the user logs in to the
> > system, the JS framework sends a question to the backend, and gets a
> > new XML layout which is used to update the tree.
> > That's okay, BUT: The new tree is generated below the old one, instead
> > of replacing it...
> > When I reload the entire page with the browser's reload button, the
> > menutree is okay, and the orphant nodes disappear.
> > Obviously, that's not a nice behaviour, so I'm thinking of a way to
> > tellMooTreeto replace the tree, instead of just adding the nodes to