Last active
August 29, 2015 14:17
-
-
Save rjsheperd/85033cae27c09d445192 to your computer and use it in GitHub Desktop.
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
// Set up global May Day object (md) to attach functions to | |
var md = md || {}; | |
(function($, md) { | |
// dollar sign ($) == jQuery | |
// Can add new functions to the jQuery prototype | |
$.fn.newFunction = function() { | |
return true; | |
} | |
// Can add functions to the global May Day object to be used later | |
md.helloWorld = function() { | |
return 'Hello World'; | |
} | |
// Can also attach properties to the May Day object | |
md.senators = { | |
California: ['Boxer', 'Feinstein'], | |
}; | |
// | |
$('#derp').on('click', function() { | |
var text = md.helloWorld; | |
console.log(text); | |
}); | |
$.ready(function() { | |
alert('All systems are go'); | |
}); | |
})(jQuery, md); | |
// Mayday object is accessible outside of the module! | |
var hello = md.helloWorld(); | |
if (md.senators.California[0] == 'Boxer') { | |
console.log('huzzah!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment