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.
有人知道怎么做吗?
查看(表单,选择输入未显示)
view (form, select input not shown)
<div class="stripe-controls" align="center">
<script src="aHR0cHM6Ly9idXR0b24uc3RyaXBlLmNvbS92MS9idXR0b24uanM=" 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.
这篇关于在条纹按钮上设置数据属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在条纹按钮上设置数据属性


- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01