I'm currently exploring the functionality of addons in Recurly.js v3.
For my form, I've linked a recurly.Pricing
instance and added a checkbox for an optional addon:
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
When following the documentation and using data-recurly="addon"
, I encountered a JavaScript error upon form attachment:
Uncaught TypeError: Cannot read property 'addons' of undefined
This led me to believe that the correct attribute should be data-recurly="addons"
.
I have also implemented events to track price changes and addon selections:
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);
})
The issue
Upon clicking the checkbox, no price change event is triggered. I've dedicated hours to troubleshooting this without any success, so if anyone can provide guidance or relate to struggling with the documentation, it would be greatly appreciated.
Thank you in advance.