]> git.ipfire.org Git - ipfire.org.git/commitdiff
donate: Disable all buttons after submit
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Feb 2022 18:35:19 +0000 (18:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 23 Feb 2022 18:35:19 +0000 (18:35 +0000)
This helps to avoid any double-submissions of the form

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/templates/donate/donate.html

index 6337d4aaf1a4a9f10dfafc027325745707ca4d97..d78a57544bf7c29531061673725db21516398447 100644 (file)
@@ -23,7 +23,7 @@
                <div class="container">
                        <div class="row justify-content-center">
                                <div class="col-12 col-md-8">
-                                       <form action="" method="POST">
+                                       <form id="donation-form" action="" method="POST">
                                                {% raw xsrf_form_html() %}
 
                                                <div class="p-4 bg-light rounded">
                        var frequency = $("input[name='frequency']");
                        var submit    = $("#donate");
                        var modal     = $("#modal-monthly-suggestions");
+                       var form      = $("#donation-form");
 
                        // Adjust form to default currency
                        if (currency.val() == "EUR") {
                                }
                        });
 
+                       // Disable all submit buttons after the form has been submitted
+                       form.one("submit", function() {
+                               submit.prop("disabled", true);
+                               $(".monthly-amount-suggestion").prop("disabled", true);
+                       });
+
                        $(".monthly-amount-suggestion").click(function (event) {
                                // Set frequency to monthly
                                $("input[name='frequency-selector']").prop("checked", false);