I'm trying to figure out how to use addons in Recurly.js v3.
I've attached one recurly.Pricing
instance to my form and created a checkbox for one 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
If I use data-recurly="addon"
as stated in the documentation I get a Javascript error when I attach the form:
Uncaught TypeError: Cannot read property 'addons' of undefined
So I suppose that the correct value is data-recurly="addons"
.
I've also attached events to detect the price change and the addon setting:
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 problem
When I click the checkbox no price change event is triggered. I've spent a few hours on this with no result so any help would be appreciated by anyone like me that don't find proper examples in the documentation.
Thank you in advance.