invite: Fix bug when button is not enabled after error in sending invite.

There is a bug where invite button is not enabled again after sending
invite is failed, but it is enabled on successful completion of invite.

I am not able to figure out why it is behaving differently in success and
error cases, even when the code to enable button is in complete() function
and it is called in both the cases.

But, I can confirm that adding .button('reset') fixes this bug as button
is disabled using the .button('loading') call and this is according to the
bootstrap docs only. But the bootstrap docs mention that the .button(string)
method has been removed in v4.0 as mentioned here
https://getbootstrap.com/docs/3.4/javascript/.

So, as we would want to avoid using depereceated or removed methods, this
commit simply changes the code to disable the button and set the loading
text using simple jquery and this also solves the above mentioned bug.
This commit is contained in:
sahil839 2021-04-05 00:58:26 +05:30 committed by Tim Abbott
parent d9fc424e12
commit 04a856fa5b
1 changed files with 3 additions and 1 deletions

View File

@ -50,7 +50,9 @@ function beforeSend() {
// aren't in the right domain, etc.) // aren't in the right domain, etc.)
// //
// OR, you could just let the server do it. Probably my temptation. // OR, you could just let the server do it. Probably my temptation.
$("#submit-invitation").button("loading"); const loading_text = $("#submit-invitation").data("loading-text");
$("#submit-invitation").text(loading_text);
$("#submit-invitation").prop("disabled", true);
return true; return true;
} }