Skip to content

Instantly share code, notes, and snippets.

@jareware
Forked from nnarhinen/desc
Created February 7, 2012 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jareware/1758122 to your computer and use it in GitHub Desktop.
Save jareware/1758122 to your computer and use it in GitHub Desktop.
addAllFoo:sta kun kutsutaan, niin this.somProperty.doSOmething() feilaa, koska "window" -objektilla ei ole propertya "someProperty"
window.FooModel = Backbone.Model.extend({});
window.FooCollection = Backbone.Collection.extend({});
window.Foos = new FooCollection;
window.FooView = Backbone.View.extend({
someProperty: <something>,
initialize: function() {
this.collection.bind('add', this.addFoo);
this.collection.bind('reset', this.addAllFoos);
this.collection.fetch();
},
addFoo: function(model) {
this.someProperty.doSomething();
//add to dom
},
addAllFoos: function() {
this.collection.each(this.addFoo);
}
});
window.App = new FooView({ collection: window.Foos });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment