[_] jQuery losing the scope!
Alex Francis
alex.francis at gmail.com
Wed Dec 9 18:37:03 GMT 2009
On Wed, Dec 9, 2009 at 4:06 PM, jean-paul Gorman <underscore at firecast.co.uk> wrote: > Hi All > > Thanks for the response on this one. > > @Dan - Yup I totally agree the solution was to fire off the remaining > calls within the plugin via a callback from the Ajax call, passing back > the results of that call so that I can deal with a load failure. > > @Sam (boy) - Thanks for the note. I did originally think that this was > the cause of the problem, but I've now taken this variable out as it was > really used for debugging. That said I'm glad you clarified the point > for me. > > Cheers > > JP > Just to be crystal clear - this statement in your original snippet at line 4 var vid_bg_img = null; is NOT declaring a global variable. It's inside a function declaration, so the variable is scoped to that function. Since you're also declaring some other functions within this function, they will also be able to see your variable, but it's not global. Might be worth reading about closures in javascript e.g. http://www.jibbering.com/faq/faq_notes/closures.html Alex