mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-24 23:25:24 +00:00
add loading spinner after submit to login pages
This commit is contained in:
parent
c0513f7c6b
commit
8bf28a4f33
2 changed files with 44 additions and 6 deletions
|
@ -21,7 +21,7 @@
|
|||
{% bootstrap_form_errors form %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||
<form id="form-signin" class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
|
||||
{% bootstrap_field form.username layout='inline' %}
|
||||
{% bootstrap_field form.password layout='inline' %}
|
||||
|
@ -29,9 +29,28 @@
|
|||
<a href="{% url 'accounts:email_otp' %}" class="float-end">{% trans "I do not have/lost my OTP!" %}</a>
|
||||
<br>
|
||||
<div class="d-grid">
|
||||
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||
<button id="btn-signin" class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#btn-signin").click(function() {
|
||||
// disable button
|
||||
$(this).prop("disabled", true);
|
||||
// add spinner to button
|
||||
$(this).html(
|
||||
`
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
{% trans "Loading" %}...
|
||||
`
|
||||
);
|
||||
$("#form-signin").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock script%}
|
||||
|
|
|
@ -22,15 +22,34 @@
|
|||
{% trans "Incorrect username or password." %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<form class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||
<form id="form-signin" class="form-signin" method="post" role="form" aria-label="Login form">{% csrf_token %}
|
||||
<h2 class="form-signin-heading">{% trans "Sign In" %}</h2>
|
||||
<input type="text" class="form-control" name="username" placeholder="{% trans 'User' %}" autocapitalize="none" autocorrect="off" autofocus required>
|
||||
<input type="password" class="form-control" name="password" placeholder="{% trans 'Password' %}" required>
|
||||
<input type="hidden" name="next" value="{{ next }}">
|
||||
<div class="d-grid">
|
||||
<button class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||
<button id="btn-signin" class="btn btn-lg btn-success" type="submit">{% trans "Sign In" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#btn-signin").click(function() {
|
||||
// disable button
|
||||
$(this).prop("disabled", true);
|
||||
// add spinner to button
|
||||
$(this).html(
|
||||
`
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
|
||||
{% trans "Loading" %}...
|
||||
`
|
||||
);
|
||||
$("#form-signin").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock script%}
|
||||
|
|
Loading…
Reference in a new issue