mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 21:21:50 +08:00
Fix the save report alert() bug
Closes SCI-616
This commit is contained in:
parent
eec6b1403d
commit
cd360d7279
1 changed files with 12 additions and 4 deletions
|
@ -317,7 +317,12 @@ function initializeSaveReport() {
|
||||||
.on("ajax:success", function(e, xhr, opts, data) {
|
.on("ajax:success", function(e, xhr, opts, data) {
|
||||||
if (data.status == 200) {
|
if (data.status == 200) {
|
||||||
// Redirect back to index
|
// Redirect back to index
|
||||||
|
|
||||||
|
// Turn off all hooks related to alert window
|
||||||
ignoreUnsavedWorkAlert = true;
|
ignoreUnsavedWorkAlert = true;
|
||||||
|
$(window).off('beforeunload');
|
||||||
|
$(document).off('page:before-change');
|
||||||
|
|
||||||
$(location).attr("href", xhr.url);
|
$(location).attr("href", xhr.url);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -439,9 +444,6 @@ function initializeUnsavedWorkDialog() {
|
||||||
var alertText = dh.attr('data-unsaved-work-text');
|
var alertText = dh.attr('data-unsaved-work-text');
|
||||||
|
|
||||||
ignoreUnsavedWorkAlert = false;
|
ignoreUnsavedWorkAlert = false;
|
||||||
if ( ignoreUnsavedWorkAlert ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(window).on("beforeunload", function() {
|
$(window).on("beforeunload", function() {
|
||||||
$(window).off('beforeunload');
|
$(window).off('beforeunload');
|
||||||
|
@ -451,7 +453,13 @@ function initializeUnsavedWorkDialog() {
|
||||||
|
|
||||||
$(document).on("page:before-change", function() {
|
$(document).on("page:before-change", function() {
|
||||||
var exit;
|
var exit;
|
||||||
exit = confirm(alertText);
|
if (ignoreUnsavedWorkAlert) {
|
||||||
|
console.log('TRUE');
|
||||||
|
exit = true;
|
||||||
|
} else {
|
||||||
|
console.log('FALSE');
|
||||||
|
exit = confirm(alertText);
|
||||||
|
}
|
||||||
if ( exit ) {
|
if ( exit ) {
|
||||||
// We leave the page so remove all listeners
|
// We leave the page so remove all listeners
|
||||||
$(window).off('beforeunload');
|
$(window).off('beforeunload');
|
||||||
|
|
Loading…
Reference in a new issue