Skip to content

Instantly share code, notes, and snippets.

@givanse
Forked from alejandro/app.js
Last active August 29, 2015 14:02
Show Gist options
  • Save givanse/a3b945a47438d7119989 to your computer and use it in GitHub Desktop.
Save givanse/a3b945a47438d7119989 to your computer and use it in GitHub Desktop.
A Disqus component for Ember.js
<div id="disqus_thread"></div>
App.CDisqusComponent = Em.Component.extend({
didInsertElement: function () {
var page_id = window.location.href,
disqus_identifier = page_id,
disqus_url = page_id,
disqus_title = Em.$('title').text(),
disqus_shortname = 'disqus shortname', // CHANGE, USE YOURS
el_id = disqus_shortname + Date.now();
this.set('page_id', el_id);
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
dsq.id = el_id;
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(dsq);
},
willDestroyElement: function () {
Em.$('#' + this.get('page_id')).remove();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment