In trying to clean up the jQuery $(document).ready function in some of my scripts. Instead of having lots of functions inside that function I’ve been creating an object literal that has properties for the functionality I’m adding to the page like so:
var taskPage = {
init: function() {
this.validate();
this.changeActivityType();
},
validate: function() {...
},
changeActivityType: function() {...
}
};
Should I put this object literal in the global namespace or should I put this object in the jQuery namespace somehow?
Global namespace is a no no!
You can enclose it in a self-executing anonymous function.