diff --git a/js/src/database/operations.js b/js/src/database/operations.js
index 85d37e3832..a85da90ee7 100644
--- a/js/src/database/operations.js
+++ b/js/src/database/operations.js
@@ -106,9 +106,10 @@ AJAX.registerOnload('database/operations.js', function () {
if (typeof data !== 'undefined' && data.success === true) {
if ($('#checkbox_switch').is(':checked')) {
CommonParams.set('db', data.newname);
- CommonActions.refreshMain(false, function () {
+ CommonActions.refreshMain(false);
+ AJAX.callback = () => {
ajaxShowMessage(data.message);
- });
+ };
} else {
CommonParams.set('db', data.db);
ajaxShowMessage(data.message);
@@ -168,12 +169,10 @@ AJAX.registerOnload('database/operations.js', function () {
// Database deleted successfully, refresh both the frames
Navigation.reload();
CommonParams.set('db', '');
- CommonActions.refreshMain(
- 'index.php?route=/server/databases',
- function () {
- ajaxShowMessage(data.message);
- }
- );
+ CommonActions.refreshMain('index.php?route=/server/databases');
+ AJAX.callback = () => {
+ ajaxShowMessage(data.message);
+ };
} else {
ajaxShowMessage(data.error, false);
}
diff --git a/js/src/modules/common.js b/js/src/modules/common.js
index af92e26915..1723a1c50d 100644
--- a/js/src/modules/common.js
+++ b/js/src/modules/common.js
@@ -1,5 +1,4 @@
import $ from 'jquery';
-import { AJAX } from './ajax.js';
import { Navigation } from './navigation.js';
/**
@@ -130,11 +129,10 @@ const CommonActions = {
*
* @param {any} url Undefined to refresh to the same page
* String to go to a different page, e.g: 'index.php'
- * @param {function | undefined} callback
*
* @return {void}
*/
- refreshMain: function (url, callback = undefined) {
+ refreshMain: function (url) {
var newUrl = url;
if (! newUrl) {
newUrl = $('#selflink').find('a').attr('href') || window.location.pathname;
@@ -149,9 +147,6 @@ const CommonActions = {
.appendTo('body')
.trigger('click')
.remove();
- if (typeof callback !== 'undefined') {
- AJAX.callback = callback;
- }
}
};
diff --git a/js/src/modules/functions.js b/js/src/modules/functions.js
index 341fbd735a..87dcb2c4c3 100644
--- a/js/src/modules/functions.js
+++ b/js/src/modules/functions.js
@@ -1833,9 +1833,7 @@ Functions.onloadCreateTableEvents = function () {
var tablesTable = $('#tablesForm').find('tbody').not('#tbl_summary_row');
// this is the first table created in this db
if (tablesTable.length === 0) {
- CommonActions.refreshMain(
- CommonParams.get('opendb_url')
- );
+ CommonActions.refreshMain(CommonParams.get('opendb_url'));
} else {
/**
* @var curr_last_row Object referring to the last
element in {@link tablesTable}
diff --git a/js/src/sql.js b/js/src/sql.js
index 458e18f708..36517724a1 100644
--- a/js/src/sql.js
+++ b/js/src/sql.js
@@ -841,12 +841,13 @@ AJAX.registerOnload('sql.js', function () {
} else {
url = 'index.php?route=/server/sql';
}
- CommonActions.refreshMain(url, function () {
+ CommonActions.refreshMain(url);
+ AJAX.callback = () => {
$('#sqlqueryresultsouter')
.show()
.html(data.message);
highlightSql($('#sqlqueryresultsouter'));
- });
+ };
}
$('.sqlqueryresults').trigger('makegrid');
diff --git a/js/src/table/operations.js b/js/src/table/operations.js
index 07c5fed372..9844127d29 100644
--- a/js/src/table/operations.js
+++ b/js/src/table/operations.js
@@ -91,9 +91,10 @@ AJAX.registerOnload('table/operations.js', function () {
'table',
$form.find('input[name=\'new_name\']').val()
);
- CommonActions.refreshMain(false, function () {
+ CommonActions.refreshMain(false);
+ AJAX.callback = () => {
ajaxShowMessage(data.message);
- });
+ };
} else {
ajaxShowMessage(data.message);
}
@@ -117,9 +118,10 @@ AJAX.registerOnload('table/operations.js', function () {
if (typeof data !== 'undefined' && data.success === true) {
CommonParams.set('db', data.params.db);
CommonParams.set('table', data.params.table);
- CommonActions.refreshMain('index.php?route=/table/sql', function () {
+ CommonActions.refreshMain('index.php?route=/table/sql');
+ AJAX.callback = () => {
ajaxShowMessage(data.message);
- });
+ };
// Refresh navigation when the table is copied
Navigation.reload();
} else {
@@ -166,10 +168,11 @@ AJAX.registerOnload('table/operations.js', function () {
$.post($form.attr('action'), $form.serialize(), function (data) {
if (typeof data !== 'undefined' && data.success === true) {
CommonParams.set('table', data.params.table);
- CommonActions.refreshMain(false, function () {
+ CommonActions.refreshMain(false);
+ AJAX.callback = () => {
$('#page_content').html(data.message);
highlightSql($('#page_content'));
- });
+ };
// Refresh navigation when the table is renamed
Navigation.reload();
} else {
@@ -290,12 +293,10 @@ AJAX.registerOnload('table/operations.js', function () {
// Table deleted successfully, refresh both the frames
Navigation.reload();
CommonParams.set('table', '');
- CommonActions.refreshMain(
- CommonParams.get('opendb_url'),
- function () {
- ajaxShowMessage(data.message);
- }
- );
+ CommonActions.refreshMain(CommonParams.get('opendb_url'));
+ AJAX.callback = () => {
+ ajaxShowMessage(data.message);
+ };
} else {
ajaxShowMessage(data.error, false);
}
@@ -324,12 +325,10 @@ AJAX.registerOnload('table/operations.js', function () {
// Table deleted successfully, refresh both the frames
Navigation.reload();
CommonParams.set('table', '');
- CommonActions.refreshMain(
- CommonParams.get('opendb_url'),
- function () {
- ajaxShowMessage(data.message);
- }
- );
+ CommonActions.refreshMain(CommonParams.get('opendb_url'));
+ AJAX.callback = () => {
+ ajaxShowMessage(data.message);
+ };
} else {
ajaxShowMessage(data.error, false);
}
diff --git a/js/src/table/relation.js b/js/src/table/relation.js
index 07ecaef182..71e18e6746 100644
--- a/js/src/table/relation.js
+++ b/js/src/table/relation.js
@@ -247,9 +247,10 @@ AJAX.registerOnload('table/relation.js', function () {
$.post(url, params, function (data) {
if (data.success === true) {
ajaxRemoveMessage($msg);
- CommonActions.refreshMain(false, function () {
+ CommonActions.refreshMain(false);
+ AJAX.callback = () => {
// Do nothing
- });
+ };
} else {
ajaxShowMessage(window.Messages.strErrorProcessingRequest + ' : ' + data.error, false);
}