From bd0bf100a26e86145a4bc8007574ed207fda84d2 Mon Sep 17 00:00:00 2001 From: Tihomir Trifonov Date: Fri, 13 Jul 2012 09:50:17 +0300 Subject: [PATCH] Added 'always-enabled' submit button selector In case when we do not want to disable a form button after form submit, it can be marked as . Fixes bug 1011527 Change-Id: I176844a3c69cdf260cb40a6574ae34b6a36ee2a0 --- .../settings/ec2/templates/ec2/download_form.html | 2 +- .../settings/project/templates/project/_openrc.html | 2 +- horizon/static/horizon/js/horizon.forms.js | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/horizon/dashboards/settings/ec2/templates/ec2/download_form.html b/horizon/dashboards/settings/ec2/templates/ec2/download_form.html index b951a0504..05c427a7c 100644 --- a/horizon/dashboards/settings/ec2/templates/ec2/download_form.html +++ b/horizon/dashboards/settings/ec2/templates/ec2/download_form.html @@ -20,6 +20,6 @@ {% endblock %} {% block modal-footer %} - + {% if hide %}{% trans "Cancel" %}{% endif %} {% endblock %} diff --git a/horizon/dashboards/settings/project/templates/project/_openrc.html b/horizon/dashboards/settings/project/templates/project/_openrc.html index 9c0f89e5b..039d641fa 100644 --- a/horizon/dashboards/settings/project/templates/project/_openrc.html +++ b/horizon/dashboards/settings/project/templates/project/_openrc.html @@ -27,6 +27,6 @@ {% endblock %} {% block modal-footer %} - + {% if hide %}{% trans "Cancel" %}{% endif %} {% endblock %} diff --git a/horizon/static/horizon/js/horizon.forms.js b/horizon/static/horizon/js/horizon.forms.js index 832f8b448..8b41d4a84 100644 --- a/horizon/static/horizon/js/horizon.forms.js +++ b/horizon/static/horizon/js/horizon.forms.js @@ -17,11 +17,14 @@ horizon.forms = { horizon.addInitFunction(function () { // Disable multiple submissions when launching a form. $("form").submit(function () { - $(this).submit(function () { + var button = $(this).find('[type="submit"]'); + if (button.length && !button.hasClass('always-enabled')){ + $(this).submit(function () { return false; - }); - $('input:submit').removeClass('primary').addClass('disabled'); - $('input:submit').attr('disabled', 'disabled'); + }); + button.removeClass('primary').addClass('disabled'); + button.attr('disabled', 'disabled'); + } return true; });