I'm getting this error:
Attempted to handle event
loadedDataon while in state rootState.loaded.updated.uncommitted.
My controller is really simple:
App.JudgeController = Ember.ObjectController.extend({
isEditing: false,
edit: function() { this.set('isEditing', true); },
done: function() { this.get("store").commit(); this.set('isEditing', false); }
});
I have a form hooked up, here's a simplified version:
<button class="btn btn-link" {{action 'edit'}} {{bindAttr disabled='isEditing'}}>Edit</button>
{{#if isEditing}}
{{view Ember.TextField placeholder="First Name" valueBinding="firstname"}}
<button type="button" class="btn btn-primary" {{action 'done'}}>Done</button>
{{#if isEditing}}
I have a navbar at the top. So the user can click the navbar and leave the page while they're editing, without clicking the Done button. Then if they go back to that page, they get that error that I mentioned at the beginning.
What do I do about this? I have a bunch of forms, and they all have a similar issue. Is there a best practice?
Maybe there a way to have a method on my controller called when the user navigates away? Then I could either rollback, or display a warning to the user and/or keep them from leaving.
Edit: I'm currently using RC5 of Ember.js. But I'm not opposed to upgrading it. I'm not really in love with the willTransition solution (maybe because it's in the router, whereas right now all my logic is in the controller, and it feels a bit messy). I guess I'll see what other answers I get before I upgrade.