Skip to content

Commit 6fab4f0

Browse files
authored
Update text only on clicked button on application form (#4773)
Fixes #4771 Add "…" to the button text on the clicked button instead of setting "Submitting..." as the text on all of them when one was clicked.
1 parent 20bffb1 commit 6fab4f0

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

hypha/apply/funds/templates/funds/application_base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ <h4>
100100
<button
101101
class="w-full sm:w-auto btn btn-primary"
102102
type="submit"
103+
name="submit"
103104
disabled
104105
>
105106
{% trans "Submit for review" %}

hypha/static_src/javascript/application-form.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,23 @@
4747
}
4848

4949
// Block multiple form submits.
50+
let clickedButton = null;
51+
submitButtons.forEach(function (button) {
52+
button.addEventListener("click", function () {
53+
clickedButton = button;
54+
});
55+
});
56+
5057
form.addEventListener("submit", function () {
5158
// Use setTimeout with 0 delay to ensure form submission begins
5259
// before the buttons are disabled, allowing their values to be included
5360
setTimeout(function () {
5461
submitButtons.forEach(function (button) {
5562
button.setAttribute("disabled", "disabled");
56-
if (button.textContent) {
57-
button.dataset.originalText = button.textContent;
58-
button.textContent = "Submitting...";
59-
}
6063
});
64+
if (clickedButton && clickedButton.textContent) {
65+
clickedButton.textContent = clickedButton.textContent.trim() + "…";
66+
}
6167
}, 0);
6268
});
6369

0 commit comments

Comments
 (0)