Reputation: 1264
let's say I have a ParentObject that hasMany Items. I want to implement my Cancel feature in my Add route that will rollback everything.
In a nutshell, I have :
ParentObject that IsNew and IsDirty
and potentially...
Items[] that will also be IsNew and IsDirty
So basically, I simply want to kill those within my NewController...
Here come the faulty code :
this.get("items").forEach(function(item)
{
item.deleteRecord();
});
this.get("model").rollback();
// Some redirection stuff
As simple as it may looks, it crashes...
Here's the console output for the crash
Uncaught Error: Attempted to handle event `didSetProperty` on <App.ParentObject:ember572:fixture-0> while in state root.deleted.saved. Called with {name: number, oldValue: undefined, originalValue: undefined, value: undefined}.
If someone could figure out what may be faulty and explain what I'm doing wrong, would be pretty appreciated !
EDIT **
I played around with transaction and clearing the relationships with no success...
Upvotes: 3
Views: 434
Reputation: 908
I JUST ran into this. For me it was happening because I had observers in operation when I was performing the rollback. I had to prevent them from firing by adding in a check in the function to check for "model.isDeleted". If it wasn't, I let it through, otherwise prevent it. That seemed to solve it for me.
Upvotes: 2