dont "var" the variable 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of stratboy
Sent: Thursday, 18 December 2008 10:20 PM
To: MooTools Users
Subject: Re: IE(6) and variables in domready



Ok, after all these slightly off-topic post, I, only for reference,
write the temporary solution I've found to MY problem:

I for some reason must add mainMenu to the window object, to have all
the app working in IE6 (and maybe 7).

So, first .js file:

window.addEvent('domready', function() {
        //NOTE THE WINDOW OBJ
        window.mainMenu = new Menu({ menuId:'menu', type:'bar',
props:mainMenu });
});

second .js file (it depends on the page):

window.addEvent('domready', function() {
        //THIS WORKS
        mainMenu.setStartButton({ mainIndex:6, subIndex:6,
openSub:true });
});

--------

@ Michal:

I thought, as you too did, that I could declare a global variable out
of the addEvent function, like this:

var mainMenu = null;

 window.addEvent('domready', function() {
        mainMenu = new Menu({ menuId:'menu', type:'bar',
props:mainMenu });
});

That way mainMenu should be global, but it doesn't work, I don't know
why. The second .js file raises an error like this:

'mainMenu is null',

Like it wasn't setted in the first domready event, and this time even
in FF.

So, for now, the only crossbrowser solution is to add mainMenu to the
window object.
That's all for now. Bye!


Reply via email to