Is there a way to make a function private in backbone, so that it is only exposed to the model itself and also have access to this ?
How can I make updateTime private?
var Timeline = Backbone.Model.extend({
url: 'servertime/',
start: function(){
this.fetch({
success: function(timeline, response){
timeline.updateTime();
setInterval(function() {
timeline.updateTime();
}, 60 * 1000);
}
});
},
updateTime: function(){ //How can I make this private?
this.time = ...
}
});
You can achieve this by wrapping it all up in a self-invoking anonymous function, this way you are sure that updateTime is private: