I need to embed a Javscript component (e.g. a Stripe pay button https://stripe.com/docs/checkout ) in my ember app, but apparently I can’t simply put a script tag inside the handlebar script tag.. any suggestion on how this can be done please?
Asked
Active
Viewed 368 times
0
-
Please, show how your templates looks like, is them inside – raidendev Jul 15 '14 at 08:14
1 Answers
2
Create a view and add the script in the didInsertElement hook.
Here is a working demo.
App.StripeView = Em.View.extend({
didInsertElement: function() {
var stripeScript =
'<script src="https://checkout.stripe.com/checkout.js" '+
'class="stripe-button" data-key="pk_test_6pRNASCoBOKtIshFeQd4XMUh" '+
'data-image="/square-image.png" '+
'data-name="Demo Site" '+
'data-description="2 widgets ($20.00)" '+
'data-amount="2000">'+
'</script>';
this.$().append(stripeScript);
}
});
And use it in your template like
{{view App.StripeView}}

blessanm86
- 31,439
- 14
- 68
- 79