Reputation: 25
I am using ember-data for model. The pages has two tabs, first tab is a grid with list of records. When user clicks on a row, it brings the user to the 2nd tab and load the data from database using the selected grid row id. When user loads first row, makes changes but did not save, goes back to tab 1, click another row which brings user back to 2nd tab with new model, if the user goes back to first tab and click on the row he selected first time, it brings up the changed unsaved data. The model has been refreshed from database, but the controller attribute values still keeps the unsaved changes from first user interaction. How to I refresh the attributes short of looping each controller attributes to match the new model?
Upvotes: 1
Views: 1326
Reputation: 301
My understanding is that the model is not reloaded from the server - once it's in memory, Ember Data will hold on to it, including any unsaved changes.
The way to reset any unsaved changes is to call the model's rollback()
method when you exit the second tab, which will discard any uncommitted changes. You might want to check if your user wants to save or discard their changes before doing so though.
Upvotes: 2