To prevent a double-click action, you should disable the button on the first click and then re-enable it after a certain delay. Here is an example of how you can modify your code to achieve this functionality:
<a id="SaveLetterBtn" class="button-create-letters bg-dark2 white SaveLetterBtn" href="@Url.Action("SaveLetter", "Letters")">Save Letter</a>
<script>
$(document).ready(function() {
var clicked = false;
$("#SaveLetterBtn").on("click", function(event) {
if (clicked) {
event.preventDefault();
return;
}
clicked = true;
var $this = $(this);
$this.addClass('disabled');
setTimeout(function() {
clicked = false;
$this.removeClass('disabled');
}, 1000);
});
});
</script>
In this modified code, the button is disabled on the first click and re-enabled after a delay of 1000 milliseconds (1 second). Adjust the delay as per your requirements. This delay will prevent the button from being clickable during that time frame.