I had a deeper look at the addthis widget and IMHO the code loaded from the script does some nasty things like creating a script
tag nor an iframe
etc. and being inside a handlebars
template the DOM manipulations that the widget script does won't work in tandem with ember.js
, unless the team behind addthis does something to make there widget more integration friendly.
So I had a look at some alternative sharing widgets, and sharethis does basically the same as addthis but with one big difference - I got easily working with ember.js
Basically what I've done was to create a view for the widget, and inside the didInsertElement
the widget initialization is called:
App.WidgetView = Ember.View.extend({
templateName: 'widget',
didInsertElement: function() {
stLight.options({publisher: "ur-733dae74-7b06-4fef-3f54-f60dce5ce03e", doNotHash: false, doNotCopy: false, hashAddressBar: false});
}
});
Then in another template the widget can be easily used by simply doing:
{{view App.WidgetView}}
The widget
template looks like this:
<script type="text/x-handlebars" data-template-name="widget">
<span class='st_sharethis_large' displayText='ShareThis'></span>
<span class='st_facebook_large' displayText='Facebook'></span>
<span class='st_twitter_large' displayText='Tweet'></span>
<span class='st_linkedin_large' displayText='LinkedIn'></span>
<span class='st_pinterest_large' displayText='Pinterest'></span>
<span class='st_email_large' displayText='Email'></span>
</script>
Have a look here for a working demo.
Disclaimer: Although my answer does not fix directly your problem, but maybe it helps you take a different approach by using a different sharing widget, because I guess you won't abandon ember.js
only because some obscure programmed widget does not work correctly.
Hope it helps.