在条带按钮上设置数据属性

Seo*_*ill 9 javascript jquery coffeescript stripe-payments

我无法弄清楚这一点.我检查了有关设置数据属性的其他问题,似乎是一件非常棘手的事情.

条纹按钮数量纯粹是为了美观,我每次用户更新数量选择框时都试图设置它('数据量').

每次我更改数量时选择一个警报给出正确的数量,如果我检查dom,'data-amount'属性似乎设置正确,但当我点击条纹按钮时,模态显示默认数据量,即没有.

有人知道怎么做吗?

视图(表单,选择输入未显示)

<div class="stripe-controls" align="center">
  <script src="https://button.stripe.com/v1/button.js" class="stripe-button"
      data-key="ENV['STRIPE_PUBLIC_KEY'] %>" data-amount="">
  </script>
</div>
Run Code Online (Sandbox Code Playgroud)

CoffeeScript的

$ ->
  $('#order_quantity').click(orderTotal)
  orderTotal()

orderTotal = ->
  quantity = $('#order_quantity').val()
  price = $('#ticket-price').data('url')
  total = quantity * price
  $('.stripe-button').attr('data-amount', total)
  alert total
Run Code Online (Sandbox Code Playgroud)

Ale*_*Caw 12

使用指定自定义金额 StripeCheckout.open().

注意:我在Stripe工作.