Просмотр исходного кода

Added onbeforeunload check to unsaved changes warning feature

Torkel Ödegaard 11 лет назад
Родитель
Сommit
a1d5e26f6b
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      src/app/services/unsavedChangesSrv.js

+ 6 - 0
src/app/services/unsavedChangesSrv.js

@@ -16,6 +16,12 @@ function (angular, _, config) {
     var self = this;
     var modalScope = $rootScope.$new();
 
+    window.onbeforeunload = function () {
+      if (self.has_unsaved_changes()) {
+        return "There are unsaved changes to this dashboard";
+      }
+    };
+
     this.init = function() {
       $rootScope.$on("$locationChangeStart", function(event, next) {
         if (self.has_unsaved_changes()) {