ethercreative / web-payments

Web Payments for Craft Commerce
Other
5 stars 7 forks source link

[Feature request] Reinitialize JS #3

Closed 23d1 closed 5 years ago

23d1 commented 5 years ago

I'm not sure if there is already functionality around this implemented. A way to reinitialize the button would be great.

Use case; ajaxified site loads the cart page, or a portion thereof containing the payment button html. Button needs to be reinitialized once the new html is inserted.

Would something like running window.CraftWebPayments(); suffice?

Tam commented 5 years ago

@23d1 I've added a reload function to the buttons object:

{{ craft.webPayments.button({
    items: [{ id: 1, qty: 1 }],
    js: 'window.payButton',
}) }}
window.payButton = window.payButton.reload();