Question

I am loading articles with AJAX. When I want to show their comment counts I use:

DISQUSWIDGETS.getCount();

This works. But when I load more articles and call the function again it does not show the comment counts of the articles. It also does not give any error. Is there a way to solve this problem in Javascript?

Was it helpful?

Solution

It might be something of a hack, but this works:

# Undefine disquswidgets to force a refresh also on ajax reload
window.DISQUSWIDGETS = undefined;
$.getScript("http://" + disqus_shortname + ".disqus.com/count.js");

Basically you trick Disqus into believing that the typeof is undefined, which will make it execute the same code again as it does the first time it's run.

OTHER TIPS

You should use this:

DISQUSWIDGETS.getCount({reset: true});

For more information, see here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top