I’m trying to fetch some related models using Backbone, using backbone-relational.js, and keep this action mutually exclusive from some other models/collections I have in memory. Example:
user = new Backbone.User { id: 1 }
user.fetch() # also fetches user.posts, using RABL
user_posts = @user.get('posts') # Using backbone-relational.js
first_post = @user_posts.get(1)
first_post.get('title') # => 'Old title'
first_post.set({ title: 'Some new title' }) # or whatever
posts = new Backbone.Posts()
posts.fetch()
posts.get(1).get('title') # => 'Old title'
first_post.get('title') # => 'Old title'
Now it would seem that these two things should be unrelated, and first_post should still have ‘Some new title’, but it doesn’t. : ( This is causing issues with state in some parts of my program, and it’s pretty obnoxious.
I should be clear, I want first_post.get('title') to keep its new value, 'Some new title', without calling first_post.save().
EDIT: I’m thinking now that it’s something backbone-relational is doing.
Any help would be greatly appreciated!
It turned out to be related to the backone-relational plugin: https://github.com/PaulUithol/Backbone-relational/issues/135