$scope.edit_passthru.vis_level = 0;
// TODO: add save/clone handlers here
- var modify_tracked = false;
$scope.field_modified = function() {
- if (modify_tracked) return;
- modify_tracked = true;
+ // Call attach with every field change, regardless of whether
+ // it's been called before. This will allow for re-attach after
+ // the user clicks through the unload warning. egUnloadPrompt
+ // will ensure we only attach once.
egUnloadPrompt.attach($scope);
}
.factory('egUnloadPrompt', [
'$window','egStrings',
function($window , egStrings) {
- var service = {};
+ var service = {attached : false};
// attach a page/scope unload prompt
service.attach = function($scope, msg) {
+ if (service.attached) return;
+ service.attached = true;
// handle page change
$($window).on('beforeunload', function() {
$($window).off('beforeunload');
if (service.locChangeCancel)
service.locChangeCancel();
+ service.attached = false;
}
return service;