当您想要更改线程时,您需要使用 Disqus.reset 函数。像下面这样的东西会起作用:
<script type="text/javascript">
var changeThread = function(){
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = 'new_disqus_identifier';
this.page.url = 'http://example.com/#!new_content';
this.page.title = "New Page Title";
this.language = "fr"; // only if changing the language
}
});
};
</script>
<button onclick=changeThread();>Change the Disqus thread!</button>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'ginfy';
var disqus_identifier = '<%= @posts.id %>';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>