在条带按钮上设置数据属性 [英] Setting data attribute on stripe button
问题描述
我不知道。我检查了有关设置数据属性的其他问题,似乎是一个棘手的事情。
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.
任何人都知道如何做到这一点?
Anyone know how to do this?
查看(表单,选择输入未显示)
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>
coffeescript
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
推荐答案
注意:我在Stripe工作。
Note: I work at Stripe.
这篇关于在条带按钮上设置数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!