【发布时间】:2014-03-21 03:56:10
【问题描述】:
我有使用 durandaljs 和 knockoutjs 的 SPA 页面。现在我将为我的网站实现对 disqus 插件的支持。
当我添加 disqus 时,我发现相同的 cmets 出现在具有不同 URL 的不同页面(我使用 durandal 进行 URL 重写)。
我猜这个问题的根源是我重写的 URL 由完整的 hashbang(#!) 来区分
代码如下:
var disqus_shortname = 'somename';
var disqus_identifier = context.id;
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
if (typeof DISQUS != 'undefined') {
DISQUS.reset({
reload: true,
config: function () {
this.page.title = "title" + context.id;
this.page.identifier = context.id;
this.page.url = "http://localhost:23054/#!ideas/details/" + context.id;
debugger;
}
});
}
查看:
<div id="disqus_thread"></div>
我希望有人使用带有 SPA 页面的 disqus cmets 并且知道如何帮助我解决这个问题。
【问题讨论】:
-
在我看来就像 stackoverflow.com/questions/8944287/… 的副本...
标签: javascript knockout.js durandal disqus