Skip to content

Commit

Permalink
#3 adding pop up when user try to go out without save changes on lessons
Browse files Browse the repository at this point in the history
  • Loading branch information
moacirmoda committed Aug 24, 2016
1 parent 3a7dfa5 commit 369e156
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions administration/static/js/edit-lesson/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
if(activityIndex >= 0) {
$scope.currentActivity = $scope.currentUnit.activities[activityIndex];
}

// remove pop-up that confirm if user go without save changes
window.onbeforeunload = function(){};

})['catch'](function(resp){
$scope.alert.error(httpErrors[resp.status.toString()]);
});
Expand Down Expand Up @@ -251,6 +255,13 @@
});
}
// ^^ como faz isso de uma formula angular ?

// add pop-up that confirm if user go without save changes
$scope.$watch('lesson', function(new_item, old_item) {
if(old_item.id && new_item != old_item) {
window.onbeforeunload = function(){ return true; };
}
}, true);
}
]);

Expand Down

0 comments on commit 369e156

Please # to comment.