Skip to content

Instantly share code, notes, and snippets.

@karlwestin
Created July 8, 2014 16:45
Show Gist options
  • Save karlwestin/a3a26d3a100f58cf4c5e to your computer and use it in GitHub Desktop.
Save karlwestin/a3a26d3a100f58cf4c5e to your computer and use it in GitHub Desktop.
define("models/accounts2", [
"lib/local-backbone",
"lib/local-underscore",
"models/accountProgress"
], function(
Backbone,
_,
progressModel
) {
var FlatAccounts = Backbone.Collection.extend({
initialize: function(options) {
// SETUP FOR ERROR:
// populate the 'planned' attr from account-progress
var updatePlanned = _.debounce(this.updatePlans);
this.on("add remove change:attributes.active", updatePlanned, this);
progressModel.on("change", updatePlanned, this);
},
updatePlans: function() {
//
// HERE COMES THE ERROR:
// this.each throws 'undefined is not a function' (sometimes)
this.each(function(model) {
// do something
}, this);
}
});
return FlatAccounts;
});
@stefanjudis
Copy link

And _.debounce(_.bind(this.updatePlans, this)) doesn't help?

Didn't digged into because I'm just on my phone. :)

@karlwestin
Copy link
Author

yeah that has helped in other places, just stumped on where the issue is coming from: underscore or our code

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