2

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);
})();
Andres SK
  • 10,779
  • 25
  • 90
  • 152

2 Answers2

3

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

Community
  • 1
  • 1
Darin
  • 2,071
  • 2
  • 17
  • 14
  • Hey Darin, mind helping me out as well? This is my issue: http://wordpress.stackexchange.com/questions/36499/customize-disqus-wp-plugins-mark-up-with-jquery and I cannot make your code work. – cr0z3r Dec 15 '11 at 13:42
  • I get an error page when I try to navigate to the link provided in your post on that page. I think your problem, though, is CSS precedence. You should be able to test that pretty easily by manipulating an HTML attribute instead of a CSS attribute. Like converting all H3 to H1. If that works, and I am pretty sure it will, then the problem really is an issue with how the CSS ruleset applies conflicting instructions. – Darin Dec 15 '11 at 19:49
  • Sorry, new link is http://demo.crozer.me/era-wp/guide-of-the-week-moving-objects - I have actually tried to manipulate the HTML, like changing the .text() or .html(), or removing an object. I realized that your code works if I directly write my code after the clearInterval (i.e. not inside the disqusReady function, which is outside). Furthermore, I also realized that sometimes my changes worked, and sometimes they did not. This is really driving me insane. Is there any possibility we could have a chat and you could check the site live? – cr0z3r Dec 16 '11 at 14:08
  • I've got to get ready for work and get out of here. Today and tomorrow I won't have a lot of time but I'll try to check in with you tomorrow night after 8pm CST. – Darin Dec 16 '11 at 14:10
  • cr0z3r I haven't forgotten you buddy. I had car trouble the last couple of days. Tonight I work late but tomorrow I get home a little earlier. – Darin Dec 20 '11 at 12:19
  • I actually managed to work it out. The only issue was that #disqus_thread always exists, so setting an Interval for it wasn't the appropriate solution; instead, checking whether #dsq_reply exists does the trick. Thank you either way!! – cr0z3r Dec 21 '11 at 18:52
1

This simple solution also works, although the original text appears first, then is replaced with the new text, which is less then ideal.

function disqus_callback() {
  $('#dsq-reply h3').text('Add Your Answer');
}
xchanius
  • 11
  • 1