More information about the Underscore mailing list

[_] jQuery losing the scope!

Sam Dwyer underscore404 at live.co.uk
Wed Dec 9 13:44:03 GMT 2009


Hi JP,
Apparently you've fixed the issue you were talking about, but I took a quick look at your code
and I noticed you mention below that you set the vid_bg_img var to be global - just so you're
aware, all your variables aside from base are global as none of them are prepended by var.

Assigning variables without the var keyword automatically attaches that variable to the window
object, giving them global scope (you can test this if you console.log(window); in firebug). 

Just thought you might be interested.
Cheers,
(boy)Sam


> I've set the var to have global scope line 4
> 
> You can see the code that I've written here :
> 
> http://pastie.org/734093
> 
> I'm sure that this is due to a the scope of the flag variable, but I
> think I've reached the point of seeing only trees and no wood!

 		 	   		  
_________________________________________________________________
Add your Gmail and Yahoo! Mail email accounts into Hotmail - it's easy
http://clk.atdmt.com/UKM/go/186394592/direct/01/