Hi all,
Evan and mindplay.dk at the Mootree user's group gave me some tips,
and I finally solved the problem. Here's my solution (for the original
thread see
http://groups.google.com/group/mootree/browse_thread/thread/338d346b786bbafd/c62788485e55005c?lnk=st&q=mootree):
The main error was that I've defined the menutree in the window.load
event, because this caused the CONSTRUCTOR of menutree to be called
every time the load.event occured, and gave me several instances of
menutree instead of rebuidling and overwriting the first. Obviously,
that's not the right way, so, I've rewritten my code, and now it looks
like below, and works.
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...
On 22 Okt., 18:55, keif <[EMAIL PROTECTED]> wrote:
> Let me know what you get dug up, when I've got time that I *know* I can
> dedicate I'll try to catch you for your code.
>
> -keif
>
>
>
> bofh wrote:
>
> > Hi moro,
>
> > thanks for the tip, I've posted my question in theMooTreegroup.
> > Let's see if someone there can help...
> > As it seems that some of the MooTools user group members (Keif) are
> > also interested inMooTree, I'll post the answer here also as soon as
> > I get it working, maybe with a link to theMooTreegroup thread.
>
> > Harald
>
> > On 22 Okt., 08:19, moro <[EMAIL PROTECTED]> wrote:
> >> there is specialmootreegrp:http://groups.google.com/group/mootree
>
> >> On 22 окт, 01:34, bofh <[EMAIL PROTECTED]> wrote:
>
> >> > Hi Keif,
>
> >> > unfortunatley, it's not online, since it's also a personal project
> >> > which purely "lives" on my workstation and in my IDE. Additionally, it
> >> > uses a newer Postgres version in the backend as I have on my
> >> > webserver, so, I'd need to update my server first for this, which
> >> > would interact with some other projects running there.
> >> > I can send you my javascript code, and the PHP part for the menu with
> >> > the necessary functions, if you like.
> >> > Maybe you can use it for your project, and help me gettin' mine
> >> > running?
>
> >> > Thanks,
>
> >> > Harald
>
> >> > On 21 Okt., 21:07, keif <[EMAIL PROTECTED]> wrote:
>
> >> > > Do you have the page up?
>
> >> > > I haven't dug intomootree, but it's something I may use on a
> >> > > (personal) project so I may try to tackle it in it.
>
> >> > > -keif
>
> >> > > On Oct 20, 6:40 pm, bofh <[EMAIL PROTECTED]> wrote:
>
> >> > > > Hi guys,
>
> >> > > > anyone using Mootree2 out there?
> >> > > > I'd like to use it 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
> >> > > > the old one.
> >> > > > The tree is initialized in the window.load event, so here's my code
> >> to
> >> > > > load the tree:
>
> >> > > > window.addEvent('load', function() {
> >> > > > var menutree = new MooTreeControl({
> >> > > > div: 'navigation',
> >> > > > mode: 'files',
> >> > > > grid: true,
> >> > > > theme: 'mootree2/mootree.gif',
> >> > > > // some other stuff, e.g. select handler etc.
> >> > > > },{
> >> > > > text: 'Menu',
> >> > > > open: true
> >> > > > });
> >> > > > menutree.root.clear();
> >> > > > menutree.root.load('functions/loadmenu.php?action=loadtree');
>
> >> > > > }
>
> >> > > > In the login procedure (written in PHP) I send the following back
> >> to
> >> > > > the frontend to reload the tree:
>
> >> > > > print "<script type=\"text/javascript\">";
> >> > > > print "window.fireEvent('load');";
> >> > > > print "</script>";
>
> >> > > > I'm quite sure I'm missing something stupid, or sending the wrong
> >> > > > event, but I just can't figure it out.
>
> >> > > > Any clues??
>
> >> > > > Thanks in advance,
>
> >> > > > Harald
>
> --
> View this message in
> context:http://n2.nabble.com/Problem-with-dynamically-generated-Mootree-tp135...
> Sent from the MooTools Users mailing list archive at Nabble.com.