need to display warning before leaving application

1
when a customer is trying to exit the application and they have not saved the information that was enter i need to have a pop-up with the following message “Are you sure you want to exit? Your information will not be saved”
asked
3 answers
3

Hey Robert,


I think this is what you’re looking for: https://appstore.home.mendix.com/link/app/78474/
Or maybe this one: https://appstore.home.mendix.com/link/app/21721/

Good luck!

answered
2

Depends on how they are exiting the application. Turning of the computer gives you no chance. Closing the browser, should be possible since there are applications doing that, stackoverflow for instance (this forum does not :-( ). Try entering an answer there and close the page. You will see

Pgadmin is onther example that does that.

But in Mendix there is no such thing as a page-event, which could trigger a microflow handling this.

I have checked the AppStore on ‘leave page’, ‘close page’ etc, but found nothing. You probably will need to do this using javascript:

// Warning before leaving the page (back button, or outgoinglink)
window.onbeforeunload = function() {
   return "Do you really want to leave this page and lose your unsaved changes?";
};

There is the “On Any Change“-AppStoreApp which you can use to trigger this javascript and there you will have it! Your page will ask you this question if you leave while having unsaved changes!

answered
0

Will this work if user X’s out of form but not browser? Either way, I tried the JavaScript action, and it didn’t work when I closed the browser or closed the page. My steps were:

  1. Added JavaScript action with code above
  2. Added nanoflow calling the JavaScript action
  3. Added OnAnyChange widget to page
  4. Tied nanoflow to OnAnyChange widget

 

Am I missing anything? Thanks for any tips

answered