js function chaining coding : From http://net.tutsplus.com/articles/web-assets-tips-for-better-organization-and-performance/
var User = {
profile: {},
name: function(value) {
this.profile.name = value;
return this;},
job: function(value) {
this.profile.job = value;
return this;},
getProfile: function() {
return this.profile;}
};
var profile = User.name("Krasimir Tsonev").job("web developer").getProfile();
console.log(profile);
var s,
NewsWidget = {
settings: {
numArticles: 5,
articleList: $("#article-list"),
moreButton: $("#more-button")
},
init: function() {
s = this.settings;
this.bindUIActions();
},
bindUIActions: function() {
s.moreButton.on("click", function() {
NewsWidget.getMoreArticles(s.numArticles);
});
},
getMoreArticles: function(numToGet) {
// $.ajax or something
// using numToGet as param
}
};