Kaynağa Gözat

add the before you leave message before leaving the page

Olivier Massot 2 yıl önce
ebeveyn
işleme
36448e96e3
1 değiştirilmiş dosya ile 8 ekleme ve 0 silme
  1. 8 0
      components/Ui/Form.vue

+ 8 - 0
components/Ui/Form.vue

@@ -326,6 +326,14 @@ onBeforeRouteLeave((to: RouteLocationNormalized, from: RouteLocationNormalized)
   return true
 });
 
+onMounted(() => {
+  window.addEventListener('beforeunload', (event) => {
+    if (formStore.dirty === true) {
+      event.returnValue = i18n.t('quit_without_saving_warning')
+    }
+  })
+})
+
 /**
  * Quitte le formulaire sans enregistrer
  */