开发者

Disqus: change captions after success with jQuery

开发者 https://www.devze.com 2023-01-01 03:37 出处:网络
Disqus automatically places defined captions upon request. For example: Add new Comment I\'ve tried to change its value with jquery on ready():

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.getElementsBy开发者_JS百科TagName('body')[0]).appendChild(dsq);
})();


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


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

精彩评论

暂无评论...
验证码 换一张
取 消