Skip to content

Instantly share code, notes, and snippets.

@hwclass
Created June 29, 2014 14:45
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 hwclass/a34e9666faf35c3ff51c to your computer and use it in GitHub Desktop.
Save hwclass/a34e9666faf35c3ff51c to your computer and use it in GitHub Desktop.
jQuery init element structural example
var initElement = function (options) {
if (typeof options.el !== 'undefined') {
options.init();
}
}
initElement({
el : document.querySelector('.navdrawer-container'),
val : 'Test element.',
fn : {
events : {
click : function () {
console.log('clicked...');
}
}
},
init : function () {
$(this.el).on('click', this.fn.events.click);
}
});
@hwclass
Copy link
Author

hwclass commented Jun 29, 2014

It must be evaluated into a plugin or a library. This example can make the code more readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment