我试图弄清楚如何在 Recurly.js v3 中使用插件。
我已将一个recurly.Pricing
实例附加到我的表单并为一个可选插件创建了一个复选框:
HTML
<label for="plan-mobile" class="checkbox">
<input type="checkbox" value="1" data-recurly="addons" data-recurly-addon="plan+mobile" id="plan-mobile">
Mobile Version
</label>
Javascript
var pricing = recurly.Pricing();
pricing.attach(subscription_form.get(0)); // subscription_form is a jQuery object
如果我data-recurly="addon"
按照文档中的说明使用,我在附加表单时会收到 Javascript 错误:
Uncaught TypeError: Cannot read property 'addons' of undefined
所以我认为正确的值是data-recurly="addons"
.
我还附加了事件来检测价格变化和插件设置:
pricing.on('set.addon', function(addon) {
console.log('set.addon');
console.log(addon);
});
pricing.on('change', function(price){
console.log('changed price');
console.log(price);
})
问题
当我单击复选框时,不会触发价格变化事件。我已经花了几个小时没有结果,所以任何像我这样在文档中找不到合适示例的人都会感谢任何帮助。
先感谢您。