Created
June 29, 2014 14:45
-
-
Save hwclass/a34e9666faf35c3ff51c to your computer and use it in GitHub Desktop.
jQuery init element structural example
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
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); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It must be evaluated into a plugin or a library. This example can make the code more readable.