Fix onbeforeunload after submititng a form

pull/1/head
yflory 4 years ago
parent 9068c624ee
commit 369567d509

@ -1949,6 +1949,7 @@ define([
console.error(err || data.error); console.error(err || data.error);
return void UI.warn(Messages.error); return void UI.warn(Messages.error);
} }
evOnChange.fire(false, true);
window.onbeforeunload = undefined; window.onbeforeunload = undefined;
if (!update) { if (!update) {
// Add results button // Add results button
@ -2029,9 +2030,13 @@ define([
var _answers = Util.clone(answers || {}); var _answers = Util.clone(answers || {});
delete _answers._proof; delete _answers._proof;
delete _answers._userdata; delete _answers._userdata;
evOnChange.reg(function (noBeforeUnload) { evOnChange.reg(function (noBeforeUnload, isSave) {
if (noBeforeUnload) { return; } if (noBeforeUnload) { return; }
var results = getFormResults(); var results = getFormResults();
if (isSave) {
answers = Util.clone(results || {});
_answers = Util.clone(answers);
}
if (!answers || Sortify(_answers) !== Sortify(results)) { if (!answers || Sortify(_answers) !== Sortify(results)) {
window.onbeforeunload = function () { window.onbeforeunload = function () {
return true; return true;

Loading…
Cancel
Save