Unsaved Changes Message

Content Type: Module
Categories: Utility,User Interface

Overview

A module of the Unsaved Changes Message widget. This widget can be used to prevent users from leave a page or the browser window while they have unsaved changes on a form.

 

The module includes examples of this widget and a JavaScript Action to use with the JavaScript Action mode.

Documentation

Demo urlhttps://widgettesting105-sandbox.mxapps.io/p/unsaved-changes-message/employees

Unsaved Changes Message

See the GitHub ReadMe for more formatted documentation.

 

Mendix widget & module to block the user from closing the browser, closing the tab, or clicking a Mendix navigation when they have unsaved changes. This module includes the widget, the 'CheckUnsavedChangesMessage' JavaScript action, and some examples of implementation.

 

Note: the browser-based message when the user tries to close the tab or close the browser CAN NOT be customized. Most modern browsers deprecated this to mitigate malicious spam.

 

Features

  • Based on a boolean expression, dynamically enable the browser's onBeforeUnload event. 
  • Based on a boolean expression, on any Mendix navigation, execute a flow.
  • Based on a boolean expression, block any Mendix navigation with a confirmation message.
  • Tested and works in Chrome, Safari, Microsoft Edge, and Firefox- Mode 'JavaScript Action' provided in the module that provides a better UX, see the Usage section of the ReadMe
  • Ability to use a custom popup page, see the Custom Popup section of the ReadMe
  • Debug mode based on a Server Constant 'CONST_DebugUnsavedChanges'

Limitations

  • Does not detect browser back or forward buttons 
    • Willing to add this functionality if anyone can find a way in Mendix
  • The developer must manually track if the form has changes using onChange actions 
    • Willing to automate this process if there is a good, future-proof method

Usage

See the GitHub ReadMe for more formatted documentation.

Demo project

https://widgettesting105-sandbox.mxapps.io/p/unsaved-changes-message/employees 

Issues, suggestions and feature requests

https://github.com/bsgriggs/mendix-unsaved-changes-message

Development and contribution

Benjamin Griggs @2023

Releases

Version: 2.0.1
Framework Version: 9.24.5
Release Notes: fixed custom popup's demo's validation messages
Version: 2.0.0
Framework Version: 9.24.5
Release Notes: - added an option to use a custom popup - changed debug mode to a constant, so it can be controlled app-wide
Version: 1.0.1
Framework Version: 9.24.5
Release Notes: - updated the Unsaved Changes Message widget to v2.0.1
Version: 1.0.0
Framework Version: 9.24.5
Release Notes: Initial release v2.0.0 of the Unsaved Changes Message widget