简体   繁体   中英

Disable Stripe Payment Submit Button with Font Awesome

So my rails app accepts Stripe payments and the javascript for the payment action disables the Submit Payment button so a user can't hit the button multiple times. This js code:

$("#payment-form").submit(function(event) {

  // disable the submit button to prevent repeated clicks
  $('.submit-button').attr("disabled", "disabled");

What I'd like to do is add some text with a spinning wheel say for example something like this:

"<i class='fa fa-spinner fa-spin'></i> Payment Processing..."

In other parts of the code for other non-stripe related actions, I used something like this:

<%= f.button "Submit", class: "btn btn-primary btn-lg btn-block", data: {disable_with: "<i class='fa fa-spinner fa-spin'></i> Signing up..."} %>

How do I add this Font Awesome functionality to my javascript here?

Why dont you just put it on a div... and you manipulate a class on that div to show or hide based on the req status? like:

$("#payment-form").submit(function(event) {
      $(".loader").show();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM