Skip to content

Instantly share code, notes, and snippets.

Created January 19, 2017 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/18403a278318ad0da9ceae18b1829744 to your computer and use it in GitHub Desktop.
Save anonymous/18403a278318ad0da9ceae18b1829744 to your computer and use it in GitHub Desktop.
example of breaking jquery code up into features
var Modal = {
open: false,
init: function() {
$('.modal-trigger').on('click', function() {
if (!Modal.open) {
Modal.open()
} else {
Modal.close()
}
})
}
open: function() {
$('.modal-wrap').show()
Modal.open = true
},
close: function() {
$('.modal-wrap').hide()
Modal.open = false
}
}
var SomeOtherFeature = {
init: function() {
...
}
...
}
$(document).ready(function() {
Modal.init()
SomeOtherFeature.init()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment