I am trying to work with Disqus api and I need to run some javascript code that modify Disqus comments thread.
How to run the javascript code after Disqus thread has loaded?
I ran into a similar issue. The only working solution I was able to come up with was to run setInterval()
to check the height of the Disqus container div.
Example:
var editable = true; // set a flag
setInterval(function() {
// Initially Disqus renders this div with the height of 0px prior to the comments being loaded. So run a check to see if the comments have been loaded yet.
var disqusHeight = $('#dsq-2').height();
if ( disqusHeight > 0 ) {
if (editable) { // To make sure that the changes you want to make only happen once check to see if the flag has been changed, if not run the changes and update the flag.
editable = false;
// Your code here...
}
}
}, 100);
Try this:
function disqus_config() {
this.callbacks.onReady.push(function () {
// your code
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With