Created
May 1, 2012 19:24
-
-
Save Boztown/2570685 to your computer and use it in GitHub Desktop.
Javascript: Namespaced Javascript Template
This file contains hidden or 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
/* | |
Self invoking anonymous function assigned to the yournamespacechoice global variable. Serves the effect of keeping all functions and variables private to this function. To expose a function or variable we must explictly return it at the bottom of the function. Remaps jQuery to $. | |
*/ | |
var yournamespacechoice = (function ($) { | |
var publicfunction; | |
function privatefunction() { | |
// function only available within parent function | |
} | |
publicfunction = function publicfunction() { | |
// public function available outside of this funtion | |
}; | |
// Expose any functions that we need to access outside of this scope. Use yournamespacechoice.functionName() to call them. | |
return { | |
publicfunction: publicfunction | |
}; | |
}(window.$)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment