Skip to content

Instantly share code, notes, and snippets.

@rorysaur
Created April 26, 2014 22:04
Show Gist options
  • Save rorysaur/11332353 to your computer and use it in GitHub Desktop.
Save rorysaur/11332353 to your computer and use it in GitHub Desktop.
purpose of app-wide bases in backbone
App.Views.ViewBase = Backbone.View.extend({
childViews: [],
addChild: function(view) {
// etc
},
close: function() {
this.childViews.forEach(function(childView) {
childView.close();
});
this.remove();
},
removeChild: function(view) {
// etc
}
});
App.Views.MinersIndex = App.Views.ViewBase.extend({
});
App.Collections.CollectionBase = Backbone.Collection.extend({
parse: function(data) {
// perhaps all calls to your api come back with stuff in the 'results' property
return data.results;
}
});
@gotno
Copy link

gotno commented Apr 27, 2014

damn it, rory. you're the ninja everyone is looking for.

@Supernats
Copy link

rockstar ninja unicorn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment