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 <input class="always-enabled">.

Fixes bug 1011527

Change-Id: I176844a3c69cdf260cb40a6574ae34b6a36ee2a0
This commit is contained in:
Tihomir Trifonov 2012-07-13 09:50:17 +03:00
parent 40e34c3000
commit bd0bf100a2
3 changed files with 9 additions and 6 deletions

View File

@ -20,6 +20,6 @@
{% endblock %}
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Download EC2 Credentials" %}" />
<input class="btn btn-primary pull-right always-enabled" type="submit" value="{% trans "Download EC2 Credentials" %}" />
{% if hide %}<a href="{% url horizon:settings:ec2:index %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>{% endif %}
{% endblock %}

View File

@ -27,6 +27,6 @@
{% endblock %}
{% block modal-footer %}
<button class="btn btn-primary pull-right" type="submit">{% trans "Download RC File" %}</button>
<button class="btn btn-primary pull-right always-enabled" type="submit">{% trans "Download RC File" %}</button>
{% if hide %}<a href="{% url horizon:settings:project:index %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>{% endif %}
{% endblock %}

View File

@ -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;
});