app/assets/javascripts/backbone-nested-attributes/model.js in backbone-nested-attributes-0.4.4 vs app/assets/javascripts/backbone-nested-attributes/model.js in backbone-nested-attributes-0.5.0

- old
+ new

@@ -151,12 +151,19 @@ collection.model = _(relation).result('relatedModel') || collection.model collection.deletedModels = new Backbone.Collection collection.deletedModels.model = collection.model + collection.on('add', nestedModelAdded) collection.on('remove', nestedModelRemoved) return collection + } + + function nestedModelAdded(model, collection) { + if (model.get('_destroy')) { + collection.remove(model) + } } function nestedModelRemoved(model, collection) { if (!model.isNew()) { model.set({ _destroy: true })