How do I warn a user of unsaved form changes before leaving a page?

I’m currently working on project based on moqui and have encountered a challenge that I hope you can help me with.

In my application, I want to implement a feature that alerts users if they try to leave the page without saving their form changes, to prevent any data loss.

Does anyone have any suggestions or example code on how to achieve this? Any tips or guidance would be greatly appreciated!

Thank you in advance!

1 Like

I sort it out by myself. Please refer moqui.webrootVue.setUrl() in moqui-xapps/screen/xstatic/WebrootVue.qvt.js at main · hellozhangwei/moqui-xapps · GitHub if you are interested.