#75 Are You Sure


Emad Ibrahim
Sep 12, 2016 · 1 min read

Tip Stolen* from EmberScreencasts Episode 170:

Here is a very simple way to prompt the user if they want to navigate away before saving their data. The last thing you want is for them to fill out a long form then accidentally navigate away.

In your route, you would add something like this:

actions: {
if(!confirm('You have unsaved changes.  Are you sure you want to leave this page?')){

You will have to implement the isDirty property in your controller to indicate the state of your model. In the screencast, Jeffrey uses ember-changeset to accomplish that. See the related tips 61 and 62.

*stolen with permission for Jeffrey — thank you.

Emad Ibrahim

Written by

Husband, Father of Twins, Published Author, Entrepreneur, Passionate Technologist, Programmer and Productivity Nut. more at https://about.me/eibrahim