在条纹按钮上设置数据属性
我想不通.我检查了有关设置数据属性的其他问题,似乎是一件很棘手的事情.
I can't figure this out. I checked other questions regarding setting data attributes, seems to be a tricky enough thing.
条纹按钮数量纯粹是为了美观,每次用户更新数量选择框时,我都会尝试设置它('data-amount').
The stripe button amount is purely for aesthetics, I'm trying to set it ('data-amount') each time a user updates the quantity select box.
每次我更改数量时,选择一个警报都会给出正确的数量,如果我检查 dom,'data-amount' 属性似乎设置正确,但是当我单击条纹按钮时,模式显示默认数据量,即什么都没有.
Every time I change the quantity select an alert gives the correct amount and if I inspect the dom the 'data-amount' attribute appears to be set correctly but when I click the stripe button the modal shows the default data-amount, i.e nothing.
有人知道怎么做吗?
查看(表单,选择输入未显示)
view (form, select input not shown)
<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>
咖啡脚本
$ ->
$('#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
推荐答案
使用 StripeCheckout 指定自定义金额.open()
.
注意:我在 Stripe 工作.
Note: I work at Stripe.
相关文章