Is “return this” necessary at the end of every method within a Backbone view?
render: function() {
this.editElem();
// I realize it wouldn't be necessary here, but...
},
renderElem: function() {
this.$el.addClass('foobar');
return this // is this one necessary?
},
EDIT
What about this example?
render: function() {
this.editElem();
},
renderElem: function() {
this.$el.addClass('foobar');
return this;
},
To quote what the official documentation says
So no it’s not necessary but it’s probably a good idea.
In general you will see it in methods that modify/render the view’s
el, by returningthisin one of those methods you are making it easier to access the view’sel, so that you can now do something likeinstead of doing it in two lines like