I added an id (ralph_submit_button) to the submit:
<button id="ralph_submit_button" class="button" type="submit" style="color: white;"><span>Approve Transaction</span></button>
I modified the recommended javascript as
<script>
var form = document.querySelector('#payment-form');
var client_token = "<%= @client_token %>";
braintree.dropin.create({
authorization: client_token,
container: '#bt-dropin',
paymentOptionPriority: ['card'],
// paypal: {
// flow: 'vault'
// }
}, function (createErr, instance) {
form.addEventListener('submit', function (event) {
<%# See : https://stackoverflow.com/questions/13831601/disabling-and-enabling-a-html-input-button %>
document.getElementById("ralph_submit_button").disabled = true;
event.preventDefault();
instance.requestPaymentMethod(function (err, payload) {
if (err) {
console.log('Error', err);
return;
}
// Add the nonce to the form and submit
document.querySelector('#nonce').value = payload.nonce;
form.submit();
});
});
});
</script>
Try as I might, I could not get a spinner to work with Braintree.
Others might want to look at https://github.com/tcannonfodder/submit-button-spinner/blob/master/demo.html . You might have more success than I. The code in https://github.com/tcannonfodder/submit-button-spinner/blob/master/demo.html seems to work well but I was unable to integrate that code into my Braintree code.