I am looking best practices in Ember.JS to fix the following scenario:
- The user clicks on the challenges link.
- The system displays the list of challenges.
- The user clicks on edit challenge button.
- The system displays the edit challenge form.
- The user updates the challenge name.
- The user clicks on the leagues link without saving the challenge.
- The system displays the list of leagues.
- The user clicks on the challenges link.
- The system displays the list of challenges with the updated challenge name.
This issue is occurring because all my text field are binded directly to the challenge model and since the model is updated as soon as you type it updates the text on all the routes. I have a cancel button on the edit form where I do this.get('model').rollback() on the model to cancel out the edits. However this gets messy if you start doing rollback in different place on the page you can click.
The way I was thinking about fixing this issue is to have the form field binded to the controller properties and on each route copy the model properties to the controller properties on the setupController hook. This would prevent edits to impact the other routes.
I am wondering if this best practice in ember or is there a better way to fix this issue?
Thank you
willTransition
hook. – user663031