Created
September 1, 2011 17:34
-
-
Save srkirkland/1186718 to your computer and use it in GitHub Desktop.
Template for creating componentized javascript design
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
(function (purchasing, $) { | |
//Private Property | |
var options = {}; | |
//Public Property | |
purchasing.AddressData = { Id: null, Name: 'Default' }; | |
//Public Method | |
purchasing.options = function (o) { | |
$.extend(options, o); | |
}; | |
purchasing.init = function() { | |
//Do your jquery document ready stuff in here | |
$("#element").click(function() { | |
//On click stuff | |
if (options.showAlert){ | |
alert(helper()); | |
} | |
}); | |
}; | |
//Private function | |
function helper() { | |
return "Hello, world!"; | |
}; | |
} (window.purchasing = window.purchasing || {}, jQuery)); |
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
<script> | |
//Setup your options | |
purchasing.options({ modifyUrl: '@Url.Action("EditAddress")', showAlert: true }); | |
$(function () { | |
//init the public method | |
purchasing.init(); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment