Created
March 24, 2015 13:11
-
-
Save atomgiant/581ec601b31ccf7365ea to your computer and use it in GitHub Desktop.
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
// 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