You can always kill it with fire if it doesn't work.

On Mon, Feb 16, 2009 at 2:52 AM, rpflo <[email protected]> wrote:

>
> A newbie like me gets nervous in there, that code looks whacky :P
>
> I'll give it a shot.
>
> Thanks for your help.
>
> On Feb 15, 9:33 pm, Guillermo Rauch <[email protected]> wrote:
> > Keep your code like it was before. Then add at the end of mootools:
> > window.addEvent('domready', function(){ window.store('domready', true);
> },
> > true);
> > window.addEvent('load', function(){ if(! window.retrieve('domready'))
> > window.fireEvent('domready'); }, true);
> >
> > // untested
> >
> >
> >
> >
> >
> > On Mon, Feb 16, 2009 at 2:20 AM, rpflo <[email protected]> wrote:
> >
> > > Well, when I do this:
> >
> > > window.addEvent('domready',function(){
> > >    alert('domready');
> > >    // all my code ...
> > > });
> >
> > > window.addEvent('load',function(){
> > >    alert('load');
> > >    // all my code ...
> > > });
> >
> > > in IE I get load first.  I had a function I fired in load that
> > > depended on variables from domready. IE couldn't find them and
> > > subsequently threw an error.
> >
> > > At any rate, I just did this and made it work, feels like a bandaid
> > > but ain't picky.
> >
> > > var domready = false;
> > > var loaded = false;
> >
> > > myFunction(){
> > >    // some code
> > > }
> >
> > > window.addEvent('domready',function(){
> > >    domready = true;
> > >    // all my other code ...
> > >    if(loaded) myFunction()
> > > });
> >
> > > window.addEvent('load',function(){
> > >    loaded = true
> > >    // all my code ...
> > >    if(domready) myFunction();
> > > });
> >
> > > So if load goes first then in domready I do my thing.
> > > Alternatively, if domready goes first then in load I do my thing.
> >
> > > Strange things are afoot.
> >
> > > On Feb 15, 9:02 pm, Guillermo Rauch <[email protected]> wrote:
> > > > Well, MooTools should itself add a load event to fire domready if it
> > > hasn't
> > > > been fired in my opinion. I thought this was already in place
> actually
> >
> > > > On Mon, Feb 16, 2009 at 1:59 AM, rpflo <[email protected]> wrote:
> >
> > > > > So in IE7 I'm getting my 'load' function firing before my
> 'domready'
> > > > > function.
> >
> > > > > When you load the page it loads up a bunch of thumbnail images and
> > > > > then when they are all loaded--window.addEvent('load')--I do some
> > > > > things to the interface using variables from my domready function.
> >
> > > > > Works great the first time, but if I hit refresh (images are all
> > > > > cashed) IE fires load before domready--and of course the other
> browser
> > > > > behave as expected.
> >
> > > > > Any tips on how to avoid this, or force an order or something?
> >
> > > > > Thanks!
> >
> > > > --
> > > > Guillermo Rauchhttp://devthought.com
> >
> > --
> > Guillermo Rauchhttp://devthought.com
>



-- 
Guillermo Rauch
http://devthought.com

Reply via email to