Search code examples
jquerydisqus

Disqus: change captions after success with jQuery


Disqus automatically places defined captions upon request. For example: Add new Comment

I've tried to change its value with jquery on ready():

$('#dsq-new-post h3').text('Paticipa con tu cuenta favorita');

No success :( ... how can i know when disqus script is finished parsing the data so i can change the caption value of h3?

BTW, this is Disqus' call:

(function(){
var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://xxxxxxxx.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();

Solution

  • Here is the answer andufo. It works:

    $(document).ready(function() {
      window.disqus_no_style = true;
    
      $.getScript('http://sitename.disqus.com/embed.js', function() {
        var loader = setInterval(function() {
          if($('#disqus_thread').html().length) {
            clearInterval(loader);
            disqusReady();
          }
        }, 1000);
      });
    
      function disqusReady() {
        //whatever you can imagine
      }
    });
    

    You can comment out the $.getscript line and ending }); as well as the window.disqus_no_style = true; line.

    I had a similar problem and posted this question. Mohamed attempted to answer me and his answer did not work but he'd posted a link to his code at github and I found the right answer there.

    Chrome Extension iframe dom reference disqus

    https://gist.github.com/471999