[jQuery] Re: document ready shortcut and scoping

2007-08-29 Thread DaveG
Michael Geary wrote: Ah, now I'm following you! I'm slow today. Heh -- just remember, slow is relative :) This will work: var test; jQuery ( function() { test = function() {alert('here')} } ); // and sometime later in your code, after document.ready fires test(); // test is d

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread DaveG
Erik Beeson wrote: You should be fine defining your functions outside of document.ready. I agree with your thought, but at this point in time we really want to avoid having to retest the original DOM not ready problem that we fixed with our code blitz -- it was very elusive, and very sporadi

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread Michael Geary
> >>> This does not work: > >>> jQuery ( function() { function test() {alert('here')} } ); > >>> test; // assume that test is defined at this point... > > That's what didn't make sense. You want to define test later, but > > reference it now? No, you can't do that. > Well the sample is

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread DaveG
Michael Geary wrote: You're making it too complicated there, Dave. :-) Now there's a first... not :) This does not work: jQuery ( function() { function test() {alert('here')} } ); test; // assume that test is defined at this point... That's what didn't make sense. You want to def

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread Michael Geary
> You're making it too complicated there, Dave. :-) > >function test() { alert('here'); }; >jQuery( test ); >test; // test is now defined, but (usually) not yet executed Ack, I missed the point completely, didn't I? I couldn't make sense of the original question (no offense!) so I s

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread Michael Geary
> > From: DaveG > > > > If I use the jQuery document.ready shortcut to delay the > > definition of a javascript function test(), what is the correct > > way to reference test()? > > > > This does not work: > > jQuery ( function() { function test() {alert('here')} } ); > > test; // assume

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread Erik Beeson
You should be fine defining your functions outside of document.ready. If your really want, you could do something like: var myFunction; $(document).ready(function() { myFunction = function(param1, param2) { }; ... }); Or: $(document).ready(function() { window.myFunction = function(...)

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread DaveG
> Why would you want to delay the definition of a function? I'm not really sure we need to, but it's basically some pre-existing code. One of those rush things where we had a problem with the DOM not being ready, and ended up blitzing all inline javascript with onready calls. Erik Beeson wr

[jQuery] Re: document ready shortcut and scoping

2007-08-28 Thread Erik Beeson
Why would you want to delay the definition of a function? --Erik On 8/28/07, DaveG <[EMAIL PROTECTED]> wrote: > > If I use the jQuery document.ready shortcut to delay the definition of a > javascript function test(), what is the correct way to reference test()? > > This does not work: > jQu