Created
April 15, 2011 02:00
-
-
Save themusicman/920993 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SITE = { | |
URL: 'http://google.com', | |
init: function() { | |
//bring "this" (SITE object) into scope for the anonymous function passed to the click method. | |
var self = this; | |
$('#link').click(function() { | |
/* | |
"this" is the "this" of the anonymous function passed to the jQuery click method. Which jQuery assigns the HTML element found | |
by the #link selector. So, "this" is the link. How then can we get access to the URL proptery in the SITE object? | |
*/ | |
window.location = self.URL; | |
// or, since we are treating the SITE object as a singleton we could just do ... | |
window.location = SITE.URL; | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment