Skip to content

Instantly share code, notes, and snippets.

@nnarhinen
Created February 7, 2012 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nnarhinen/1758113 to your computer and use it in GitHub Desktop.
Save nnarhinen/1758113 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() {
Foos.bind('add', this.addFoo, this);
Foos.bind('reset', this.addAllFoos, this);
Foos.fetch();
},
addFoo: function(model) {
this.someProperty.doSomething();
//add to dom
},
addAllFoos: function() {
Foos.forEach(this.addFoo);
}
});
window.App = new FooView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment