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

Setting data inside an array fires an add event on the parent array #60

Open
uplift opened this issue Sep 23, 2012 · 1 comment
Open
Labels

Comments

@uplift
Copy link

uplift commented Sep 23, 2012

I put together this jsfiddle to show what I mean.

http://jsfiddle.net/uz6VF/1/

I'd expect to only see one 'added' displayed but seeing three. I've narrowed it down to this line

https://github.com/afeld/backbone-nested/blob/master/backbone-nested.js#L262

but cant see an obvious fix. Any ideas?

@afeld
Copy link
Owner

afeld commented Sep 23, 2012

Hmm, yep, add() is using set() under the hood, but should probably be checking isNewValue (or something) before firing that event. Looking into it now.

tomhicks added a commit to tomhicks/backbone-nested that referenced this issue May 11, 2014
demonstrates issue where setting a value inside a nested array
erroneously triggers and add event, when no item has been added
tomhicks added a commit to tomhicks/backbone-nested that referenced this issue May 11, 2014
Checks whether or not the set method call will add a new item to a
nested array. If not, the ‘add’ event is not triggered where previously
it would.
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

2 participants