Skip to content

Instantly share code, notes, and snippets.

@alejandro
Last active December 24, 2015 08:29
Show Gist options
  • Save alejandro/6771308 to your computer and use it in GitHub Desktop.
Save alejandro/6771308 to your computer and use it in GitHub Desktop.
A Disqus component for Ember.js
App.CDisqusComponent = Em.Component.extend({
didInsertElement: function(){
var root_url = "website url"
, page_id = window.location.href
, disqus_identifier = page_id
, disqus_title = Em.$('title').text()
, disqus_url = page_id
, disqus_shortname = 'disqus shortname'
, el_id = disqus_shortname + Date.now()
this.set('page_id', el_id)
!function() {
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()
}
})
<div class="row" id="comments">
<div id="disqus_thread" class="col-md-8">
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment