Issue in catching menu (Top or Left) link click in Moqui

I am working on an application in Moqui. I have an app where pages are built using Quasar. Basically “.qvue” files. I have implemented unsaved alert functionality. There is one popup for selected item where additional details are available. Now if user edit something and without saving it, if tries to close this popup, I am giving user the info alert about the unsaved alert and prevent the popup close so user can save and then close it.

The above is working fine. But when the user has unsaved changes in the popup and if user clicks any of the links wither in left navigation window or top menu items, I am unable to prevent user from navigating away and display unsaved alert.

How can I prevent a user from navigating away and show my unsaved alert? Please note, I need to achieve this in the quasar page in “.qvue” file. Basically I don’t control of root navigation links of Moqui on my quasar page.

I tried to use JavaScript “onbeforeunload” event but that doesn’t work when navigating by clicking links in the menu.

Any help would be greatly appreciated.

1 Like

I’m not sure what you mean by this. You can have full control over how Moqui renders html, qvue files using this (example).


Can you share an example component that is just the code that is problematic so that I can reproduce? I often find that narrowing down the code to just the problematic part helps me fix the problem, and if not I can help you figure out how to fix that.

I can simplify the question a bit. It is not related to rendering the menu, we do not need to gain control over that unless it will be required in order solve the problem we have.
Forget about qvue screens or any customization, just think about it in terms of standard Moqui xml screens. The question is, if a user makes a change to a field on a screen and then attempts to navigate away without saving can we catch that so we can present the user with a warning that any changes they made will be lost.
It could be any screen but let’s use the Party screen as an example. If I change a field, for example entering something in the “Internal Comments” field and then forget to click the Update button before navigating away, my changes will be lost.

1 Like