add button spinner

This commit is contained in:
Johan Le Baut 2022-02-13 12:54:39 +01:00
parent d0715b0d15
commit 68b137c8f9

View file

@ -34,7 +34,7 @@
<div id="methodPto" class="collapse show testMethods"> <div id="methodPto" class="collapse show testMethods">
<h2 class="text-center form-title">Test d'éligibilité par PTO</h2> <h2 class="text-center form-title">Test d'éligibilité par PTO</h2>
<form method="post" action="/test/pto"> <form id="formPtoTest" method="post" action="/test/pto">
<div class="form-group" id="ptoForm"> <div class="form-group" id="ptoForm">
<label class="form-label" for="pto-number">Numéro PTO</label> <label class="form-label" for="pto-number">Numéro PTO</label>
<input autofocus required type="text" class="form-control" name="pto" id="pto-number" aria-describedby="ptoHelp" <input autofocus required type="text" class="form-control" name="pto" id="pto-number" aria-describedby="ptoHelp"
@ -53,7 +53,7 @@
</div> </div>
</div> </div>
</div> </div>
<button type="submit" class="btn btn-sable">Tester le PTO</button> <button id="buttonPtoTest" type="submit" class="btn btn-sable">Tester le PTO</button>
</form> </form>
<br> <br>
@ -208,10 +208,25 @@
}); });
$('#formAddressTest').submit(function(eventObj) { $('#formAddressTest').submit(function(eventObj) {
// disable button
$("#btnTestAdresse").prop("disabled", true);
// add spinner to button
$("#btnTestAdresse").html(
`<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>Test...`
);
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeInsee" value="${codeInsee}" />`); $('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeInsee" value="${codeInsee}" />`);
$('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeRivoli" value="${codeRivoli}" />`); $('#formAddressTest').append(`<input type="hidden" class="form-control" name="codeRivoli" value="${codeRivoli}" />`);
return true; return true;
}); });
$('#formPtoTest').submit(function(eventObj) {
// disable button
$("#buttonPtoTest").prop("disabled", true);
// add spinner to button
$("#buttonPtoTest").html(
`<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>Test...`
);
return true;
});
}); });
</script> </script>
</body> </body>