From d94331a2930ae7ec9beff4c114837fa706475f35 Mon Sep 17 00:00:00 2001 From: Thomas Steur <thomas.steur@gmail.com> Date: Fri, 2 Oct 2015 07:28:13 +0000 Subject: [PATCH] refs #8811 disable save button when clicking on it --- .../CoreAdminHome/javascripts/pluginSettings.js | 7 ++++++- plugins/Morpheus/javascripts/ajaxHelper.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/plugins/CoreAdminHome/javascripts/pluginSettings.js b/plugins/CoreAdminHome/javascripts/pluginSettings.js index 741b85c7f5..d6e49de450 100644 --- a/plugins/CoreAdminHome/javascripts/pluginSettings.js +++ b/plugins/CoreAdminHome/javascripts/pluginSettings.js @@ -17,6 +17,8 @@ $(document).ready(function () { function updatePluginSettings() { + $submit.prop('disabled', true); + var $nonce = $('[name="setpluginsettingsnonce"]'); var nonceValue = ''; @@ -34,7 +36,10 @@ $(document).ready(function () { ajaxHandler.redirectOnSuccess(); ajaxHandler.setLoadingElement(getLoadingElement()); ajaxHandler.setErrorElement(getErrorElement()); - ajaxHandler.send(true); + ajaxHandler.setCompleteCallback(function () { + $submit.prop('disabled', false); + }); + ajaxHandler.send(); } function getSettings() diff --git a/plugins/Morpheus/javascripts/ajaxHelper.js b/plugins/Morpheus/javascripts/ajaxHelper.js index 2413e63372..8050539192 100644 --- a/plugins/Morpheus/javascripts/ajaxHelper.js +++ b/plugins/Morpheus/javascripts/ajaxHelper.js @@ -99,6 +99,11 @@ function ajaxHelper() { */ this.errorCallback = this.defaultErrorCallback; + /** + * Callback function to be executed on complete (after error or success) + */ + this.completeCallback = function () {}; + /** * Params to be passed as GET params * @type {Object} @@ -244,6 +249,16 @@ function ajaxHelper() { this.errorCallback = callback; }; + /** + * Sets the complete callback which is called after an error or success callback. + * + * @param {function} callback Callback function + * @return {void} + */ + this.setCompleteCallback = function (callback) { + this.completeCallback = callback; + }; + /** * error callback to use by default * @@ -359,6 +374,7 @@ function ajaxHelper() { async: this.async !== false, url: url, dataType: this.format || 'json', + complete: this.completeCallback, error: function () { --globalAjaxQueue.active; -- GitLab