Skip to content
Browse files

Don't remove new objects from collections.

  • Loading branch information...
1 parent 41a0d85 commit 3dd50142950f5e64193071d206279ea16adc3154 @thomasst thomasst committed
Showing with 4 additions and 2 deletions.
  1. +4 −2 backbone-relational.js
View
6 backbone-relational.js
@@ -893,8 +893,10 @@
if ( coll instanceof Backbone.Collection ) {
// Make sure to operate on a copy since we're removing while iterating
_.each( coll.models.slice(0) , function( model ) {
- oldIds[ model.id ] = true;
- coll.remove( model, { silent: (model.id in newIds) } );
+ if ( !model.isNew() ) {
+ oldIds[ model.id ] = true;
+ coll.remove( model, { silent: (model.id in newIds) } );
+ }
});
} else {
coll = this._prepareCollection();

0 comments on commit 3dd5014

Please sign in to comment.
Something went wrong with that request. Please try again.