I would like to place all of JavaScript DOM element queries in an object and access them throughout my script. Here's the current design pattern I'm using and I would like to stick to this format if possible:
(function ($) {
EXAMPLE = {
basicExample : function () {
config : {
logo : $('#logo'),
footer : $('footer'),
},
EXAMPLE.config.logo.hover(function () {
$(this).addClass('example');
}, function () {
$(this).removeClass('example');
});
}
EXAMPLE.basicExample();
})(jQuery);
Accessing the logo DOM element doesn't seem to work like this: EXAMPLE.config.logo
configisn't a property ofEXAMPLE. It's not even a property or variable ofbasicExample- it's a label (you used:instead of=).