更新时间:2023-12-05 08:13:04
Ahha - 我已经想通了!
Ahha - I've figured it out!
这是运行TurboLinks的Rails应用程序的一部分。
This is part of a rails application running TurboLinks.
TurboLinks动态更改主体内容,而不是每创建一个新请求当你点击一个链接。这意味着我的脚本标签被动态插入,并保证它们按顺序运行。
TurboLinks dynamically changes the body content instead of creating a new request every time you click a link. This means my script tags are being inserted dynamically, and the guarantee that they're run in order is lost.
由于TurboLinks不会在每次请求时重新评估脚本标记,我认为这里最简单/***的解决方案是在我的应用程序的每个页面上包含StripeCheckout(不仅仅是需要的),在< head>
Since TurboLinks does not re-evaluate script tags on every request, I think the easiest/best solution here is to include StripeCheckout on every page of my app (not just the one's it's needed on), within the <head>
我也认为TurboLinks可以通过找到一种按顺序运行脚本的方法来解决这个问题。我打算跟进他们的github上的问题,并会相应地进行更新。
I also think TurboLinks can resolve this by finding a way to run the scripts in order. I plan to followup with an issue on their github, and will update here accordingly.