documentcloud/backbone — Issue #1028: Incorrectly nested attributes
Author: shodanuk
Created: 2012-02-19 22:19:51+00:00
State: open

I'm having an issue with Model.save(). In between the first and second attempts to save a model (in this case to localStorage using backbone.localStorge.js), the attributes of the model are being replaced with a reference to the model itself.

I've tracked it back to line 324 / 325 and it seems to be the output of model.parse() that is replaced the original model attribues.

The call to save() is made from the saveProject method of this model:

https://github.com/shodanuk/bbTodo/blob/master/public/js/app/models/projectModel.js

Essentially, what happens is the first time I add a todo to the project and save, it works. However, when saving, the attributes get overwritten as described above. When I add a second todo and try and save the project, the model.toJSON call fails as it tries to convert the circular reference to JSON. Without any meaningful error message, I may add!

Is this something I'm doing wrong or an issue with Backbone?