I'm trying to learn how to structure my jQuery code better. I'm only about a week into jQuery so if something looks way off please tell me. I'm attempting to use object literals and it appears to work ok, but I am wondering if there is possibly a better way to structure my code.
var application = {
wrapper: $('#wrapper'),
addButton: $('#add'),
init: function() {
this.addButton.click(this.buttonHandlers.clickHandler);
this.wrapper.on("contextmenu", "#wrapper div", this.buttonHandlers.contextMenuHandler);
},
buttonHandlers: {
clickHandler: function(e) {
console.log("clickyHandler");
},
contextMenuHandler: function(e) {
console.log("right click");
return false;
}
}
};
application.init();