Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resetting a collection does not re-establish bindings for models that were included both before and after that reset #70

Open
rzhou186 opened this issue Apr 12, 2015 · 3 comments
Labels

Comments

@rzhou186
Copy link
Contributor

I have a component using the Backbone.React.Component mixin that accepts a collection.

I populate this collection within my component via Backbone's Collection.reset, passing in an array of JavaScript objects with the model data (not models themselves). For example,

this.getCollection().reset([{ id: "552ac27b526179a194170000", name: "One" }, { id: "552ac27b526179a194190000", name: "Two" }]);

var one = this.getCollection().get("552ac27b526179a194170000");
var two = this.getCollection().get("552ac27b526179a194190000");

// I then pass these two models to some child components.

On the first call to Collection.reset, all of the mixin's bindings work perfectly. If I update/save one of the models from the above example within any child component, the mixin will trigger a re-render.

However, I run into an issue when I call Collection.reset again, and pass in a batch of data that has any overlap with the existing collection. Like so:

this.getCollection().reset([{ id: "552ac27b526179a194170000", name: "One" }, { id: "552ac27b526179a194120000", name: "Three" }]);

var one = this.getCollection().get("552ac27b526179a194170000");
var three = this.getCollection().get("552ac27b526179a194120000");

// I then pass these two models to some child components.

Here, the variable three will have its bindings properly established. However, one actually seems to lose its bindings! For example, when I call one.save({ name: "OneModified" }) within a child component, it won't trigger a re-render on my top-most component.

I think this is an issue with the way that reset events are handled, for models that existed both before and after the reset. Thoughts? Thanks so much!

@magalhas magalhas added the bug label Apr 15, 2015
@magalhas
Copy link
Owner

I'll try to check this when I catch some time, though my first priority is implementing an easy way of using the mixin's sugar inside an ES6 class.

@DiegoYungh
Copy link

14 Apr to 02 November, is this project still active?

@magalhas
Copy link
Owner

magalhas commented Nov 2, 2015

@DiegoYungh it's but it's kind of in maintenance mode. Meaning, I'll update things for React 0.14 when I catch my breath but I won't be developing any new features in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants