Reputation: 41595
I have tried to use Diqus comment system in my site using ajax to load the article and comments and i couldn't make it work.
I use jQuery and i load the whole article (comments included) with the action ".load".
I am using the code they provide in their site for this cases: http://docs.disqus.com/help/85/
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = "newidentifier";
this.page.url = "http://example.com/#!newthread";
}
});
I really don't know what i am doing bad. My code is this one:
$(".cargaAqui").load("http://"+ document.domain + "/myArticle"+id, function() {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = "myArticle" + id;
this.page.url = 'http://' + document.domain +'/view-'+ id+'#!newthread';
}
});
Any idea what's wrong? Thanks
Upvotes: 1
Views: 2766
Reputation: 4073
I've made a basic template with working DISQUS 2012 comments loading with ajax via jquery-pjax.
DISQUS 2012 does not work with DISQUS.reset yet, but they're working on it.
If you need DISQUS.reset to reload comments after ajax loading content, you'll need to turn off 2012 features in DISQUS admin.
[UPDATE:] DISQUS.reset has since been implemented in DISQUS 2012, so the workaround above is not really necessary. However, push state combined with DISQUS.reset work really well together.
Upvotes: 2
Reputation: 1
I agree with Adam. Disqus script tags accumulate. I did that :
var head = document.getElementsByTagName('head')[0];
head.removeChild(head.lastElementChild);
Put it just before the DISQUS function.
It works perfectly for me, because Disqus script tag is at the end of head. I run firebug again in Chrome, and Disqus script tags didn't accumulate any more.
Upvotes: 0