mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-08-24 02:41:42 +02:00
[ADD] QuerySelector function to prevent forms from double submitting
This is to prevent forms from submitting multiple times when users double-click or even more …
This commit is contained in:
parent
099a39a2a2
commit
0360184c2d
@ -15,6 +15,10 @@
|
|||||||
ul#nav-right:has(li) + ul#nav-right-character-control > li:first-child {
|
ul#nav-right:has(li) + ul#nav-right-character-control > li:first-child {
|
||||||
display: list-item !important;
|
display: list-item !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.is-submitting button[type="submit"] {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 991px) {
|
@media all and (max-width: 991px) {
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* Functions and utilities for the Alliance Auth framework.
|
||||||
|
*/
|
||||||
|
|
||||||
/* jshint -W097 */
|
/* jshint -W097 */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -267,3 +271,30 @@ function objectDeepMerge (target, ...sources) {
|
|||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the document is ready …
|
||||||
|
*/
|
||||||
|
$(document).ready(() => {
|
||||||
|
/**
|
||||||
|
* Prevent double form submits by adding a class to the form
|
||||||
|
* when it is submitted.
|
||||||
|
*
|
||||||
|
* This class can be used to show a visual indicator that the form is being
|
||||||
|
* submitted, such as a spinner.
|
||||||
|
*
|
||||||
|
* This is useful to prevent users from double-clicking the submit button
|
||||||
|
* and submitting the form multiple times.
|
||||||
|
*/
|
||||||
|
document.querySelectorAll('form').forEach((form) => {
|
||||||
|
form.addEventListener('submit', (e) => {
|
||||||
|
// Prevent if already submitting
|
||||||
|
if (form.classList.contains('is-submitting')) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add class to hook our visual indicator on
|
||||||
|
form.classList.add('is-submitting');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
{% theme_css %}
|
{% theme_css %}
|
||||||
|
|
||||||
{% include 'bundles/fontawesome.html' %}
|
{% include 'bundles/fontawesome.html' %}
|
||||||
{% include 'bundles/auth-framework-js.html' %}
|
|
||||||
{% include 'bundles/auth-framework-css.html' %}
|
{% include 'bundles/auth-framework-css.html' %}
|
||||||
|
|
||||||
|
{% include 'bundles/jquery-js.html' %}
|
||||||
|
{% include 'bundles/auth-framework-js.html' %}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@media all {
|
@media all {
|
||||||
.nav-padding {
|
.nav-padding {
|
||||||
@ -138,8 +140,6 @@
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% include 'bundles/jquery-js.html' %}
|
|
||||||
|
|
||||||
{% theme_js %}
|
{% theme_js %}
|
||||||
|
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user