Several disqus-threads on one page

前端 未结 8 1056
星月不相逢
星月不相逢 2020-12-08 04:51

we have a website where we have list a lot of events, and would like to add discussions to each of the events.

So we wanted to use disqus, and checked it out. Turns

8条回答
  •  长情又很酷
    2020-12-08 04:59

    I know this question is very old but as I have faced the same issue I found a work around that worked pretty good for me.

    I currently have a page - lets call it Album - that lists a series of images belonging to that album.

    Clicking on an image will pop up a lightbox with the current image and a special sidebar that fetches via ajax current image information such as title, date, author, comments etc.. (Very similar to facebook image viewer/sidebar comments)

    I wanted users to be able to comment on the main album page but also on the specific image they are viewing inside the lightbox sidebar.

    Thanks to some callback functions that belong to the lightbox, one was run whenever lightbox was opened, which I have used to rename temporarly the div 'disqus_thread' in the main album page to something else.

    Another callback was run whenever you changed images inside the lightbox - which allowed me to reload the sidebar information regarding the image where I have included a new disqus_thread div and a javascript forcing a disqus_reset.

    And the other callback runs when the lightbox closes which allows me to rename the album comment div back to disqus_thread and force another reset.

    So to summarize, the main page contains the comments for the album, when you click on an image I rename the original div to something else. Then some information is fetched via AJAX which contains a new disqus_thread div. I use DISQUS.reset and the comments load on the lightbox. When I close the lightbox I rename the original div back to disqus_thread and force another reset.

    I hope it helps someone!

提交回复
热议问题