The same disqus stream loads for all articles

I have SPA pages that use durandaljs and knockoutjs. Now I'm going to implement disqus plugin support for my site.

When I added disqus, I found that the same comments are displayed for different pages with different URLs (I used durandal to rewrite the URLs).

I assume the root of this problem is that my rewritten url has full hashbang (#!) enter image description here

The following code:

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

View:

<div id="disqus_thread"></div>

I hope someone uses disqus comments with SPA pages and knows how to help me solve this problem.

+3
source share
2 answers

here is my solution:

    var id = context.id;
    disqus_shortname = 'somename',
    disqus_identifier = id,
    disqus_title = id,
    disqus_url = "http://someurl.com/#!" + id;
        if ($('head script[src="http://' + disqus_shortname + '.disqus.com/embed.js"]').length == 0) {
            (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]).appendChild(dsq);
            })();
        }
        if (typeof DISQUS != "undefined") {
            DISQUS.reset({
                reload: true,
                config: function () {
                    this.page.identifier = id;
                    this.page.url = "http://someurl.com/#!" + id;
                }
            });
        }
+3
source

, , . Disqus:

Disqus , Disqus . , .

, context.id, , Disqus.

+1

All Articles