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

How to prevent caching of related models? #21

Closed
PaulUithol opened this issue Aug 24, 2011 · 2 comments
Closed

How to prevent caching of related models? #21

PaulUithol opened this issue Aug 24, 2011 · 2 comments

Comments

@PaulUithol
Copy link
Owner

Raised by @takinbo in email:

Thanks for your great library - Backbone-relational. I'm using it quite extensively in a project and I came across is very interesting scenario that seems to be a bug.

I had some models which had other related models rendered on a webpage. If I make any changes to the models (from the database) and I refresh the collection, this gets reflected on the interface however, if I make the changes to a related model (again from the backend) and refresh the collection, this related model doesn't reflect the new changes. I traced this to https://github.com/PaulUithol/Backbone-relational/blob/master/backbone-relational.js#L484 (line 484). My hack was to avoid the lookup in the store and create the model each time.

Are there any better ways to solve this problem, is my solution going to have any performance hits on my application?

Thanks.

@PaulUithol
Copy link
Owner Author

It would appear that the behavior for the models itself is governed by the code at (and around) https://github.com/PaulUithol/Backbone-relational/blob/master/backbone-relational.js#L1062 , since they are added to the collection directly.

However, the related models in your scenario indeed pass through findRelated, which causes them to be used just as they're found in the store. The behavior there should probably mimic that in the overridden collection._add; update if found in the store, create otherwise. I'll see if I can fix this.

@PaulUithol
Copy link
Owner Author

Fixed by commit @8b58c01

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

No branches or pull requests

1 participant