From a1d5e26f6b3504ff4285692cf37a27544ae5e417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 27 Apr 2014 12:27:06 +0200 Subject: [PATCH] Added onbeforeunload check to unsaved changes warning feature --- src/app/services/unsavedChangesSrv.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/services/unsavedChangesSrv.js b/src/app/services/unsavedChangesSrv.js index 682d3a4fc4b..a0d2a079d34 100644 --- a/src/app/services/unsavedChangesSrv.js +++ b/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()) {