diff --git a/plugins/CoreAdminHome/javascripts/pluginSettings.js b/plugins/CoreAdminHome/javascripts/pluginSettings.js index 741b85c7f573fc1b84e1e092103a11fa41161eea..d6e49de4508583539aa37754eb9e0b6a54c17da1 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 2413e63372462d6de0ccefcd5f809e67f0457f40..8050539192699f9e87e8c294d6a0fb36327a7511 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;