I am using Vue.js. I have a component where the user can save data. But it is possible that user has not saved the data and he tries to navigate to other route or destroy the component. I want to show a message that there is unsaved data and user really wants to leave it unsaved.
If the user says that he does not want to leave the unsaved data, then I have to stop navigation or component's destroying. I am using beforeDestroy
to check if there is unsaved data and it works but I can not stop destroying the component or navigation. I tried using beforeRouteLeave
but it does not work. Any ideas on how to make this work?