刷新DISQUS的评论数 [英] Reload the comment count of Disqus

查看:266
本文介绍了刷新DISQUS的评论数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我加载使用AJAX的文章。当我想展示自己的评论数我使用的:

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

DISQUSWIDGETS.getCount();

这工作。但是,当我装载更多的物品,并再次调用该函数不会显示文章的评论数量。它也没有给出任何错误。有没有办法解决的Javascript这个问题呢?

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?

推荐答案

它可能是一个黑客,但这个工程:

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");

基本上你欺骗DISQUS,以为将typeof是不确定的,这将使其执行同样的code又因为它第一次它的运行。

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.

这篇关于刷新DISQUS的评论数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆