Skip to content

Instantly share code, notes, and snippets.

@yashprit
Created May 30, 2014 06:31
Show Gist options
  • Save yashprit/c7cf703e1e62de93fd86 to your computer and use it in GitHub Desktop.
Save yashprit/c7cf703e1e62de93fd86 to your computer and use it in GitHub Desktop.
This is one of way to Structure jQuery Application
(function(ctx, $, undefined){
$(document).ready(function(){
bindEvent();
})
function bindEvent () {
//private scope for application
}
var _private = {
handlerOne: function () {
},
handlerTwo: function () {
}
}
ctx.intit = function () {
//this is my init function in public scope for application bootstap
};
ctx.processPrivateData = function () {
//this way we will publically
};
})(window.APP = window.APP || {}, jQuery)
@yashprit
Copy link
Author

To know about why we have used undefined refer to this URL http://stackoverflow.com/questions/9602901/what-is-the-purpose-of-passing-in-undefined, but as of now we can avoid this because mostly all browsers(IE 9+) supports write protection for undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment