2
votes

I'm struggling to understand everything about the ember model lifecycle. I have created this jsfiddle to illustrate my problem. When clicking on one of the entries in the list, editing a value, and clicking the versions link to go back to the list, I get the following error:

Uncaught Error: Attempted to handle event loadedData on while in state rootState.loaded.updated.uncommitted. Called with {}

What is causing this? I get that the object state is now dirty, but how can I force a refresh of all objects when the list is opened?

Also, any suggestions on how to discard all changes to the properties if the form is not saved? I was thinking about cloning the object, using that clone in the edit form, and merging that with the original when saving. Not as easy as I first imagined.

Using latest ember and ember-data.

1

1 Answers

3
votes

After quick discussion with @tchak, a solution could be to override the Version route's exit function, and rollback the current model.

App.VersionRoute = Ember.Route.extend({
  exit: function() {
    var controller = this.controllerFor(this.templateName),
        content = controller.get('content');

    if (content.get('isDirty')) {
      content.get('transaction').rollback(); 
    }
    this._super();
  }
});