Created
October 8, 2015 10:27
-
-
Save StefanWallin/e47b49c200e553c4801f to your computer and use it in GitHub Desktop.
Javascript jQuery namespaced functionality nugget
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
document.mittmedia = document.mittmedia || {}; | |
(function(object, jQuery, ...dependencies...){ | |
object.plugin_name = { | |
elements: { | |
}, | |
init: function(){ | |
this.gatherElements() | |
this.bindEventHandlers() | |
}, | |
gatherElements: function(){ | |
this.elements = { | |
label: { | |
abcd: $("#abcd") | |
... | |
}, | |
error_label: { | |
... | |
}, | |
input: { | |
... | |
}, | |
button: { | |
... | |
} | |
} | |
}, | |
bindEventHandlers: function(){ | |
this.elements.label.abcd.on('click', handleLabelClick); | |
this.elements.label.defg.on('click', handleLabelClick); | |
... | |
} | |
...logic... | |
}; | |
object.plugin_name.init(); | |
})(document.mittmedia, jQuery, ...dependencies...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment