Skip to content

Instantly share code, notes, and snippets.

@atomgiant
Created March 24, 2015 13:11
Show Gist options
  • Save atomgiant/581ec601b31ccf7365ea to your computer and use it in GitHub Desktop.
Save atomgiant/581ec601b31ccf7365ea to your computer and use it in GitHub Desktop.
// Setup an App namespace for all other Javascript to hook to.
var App = {};
// Watch is a utility for hooking into form changes
//
// Example:
// App.Watch.init("#company-filter", function(el){});
App.Watch = (function() {
function init(el, handler) {
$(el).on("propertychange keyup input paste", function() {
handler($(this));
});
}
return {
init: init
}
})();
// Each section or page of the app gets it's own init method which is hooked in at page load.
App.Dashboard = (function () {
function init() {
// Setup the page which handlers or whatnot
...
}
// Here is an example of another public method within the Dashboard module.
function publicMethod() {
// code goes here
}
// This method will stay "private" and not be exposed outside of the Dashboard module
// since we don't return it below.
function privateMethod() {
// code goes here
}
return {
init: init,
publicMethod: publicMethod
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment