Threaded Replies not working
-
I believe this was an issue previously however I can’t get threaded replies working on my site: http://iptvnow.dev-winn-brown.co.uk/forums/topic/general-chat/
Every time I try to click reply on a specific post, I am automatically scrolled down to the general reply box. I can confirm that threaded replies is enabled in the settings.
I have tried with 2017 theme and it is the same.
Anyone got any ideas?
-
I am having the same issue. Can anyone chime in that knows what might be happening here? It doesn’t seems like it is working on these support forums either.
Thanks!
Hello … I opened the Chrome dev console, and hitting the reply link gives me a JavaScript error:
reply.js:18 Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': 2 arguments required, but only 1 present. at Object.moveForm (reply.js:18) at HTMLAnchorElement.onclick ((index):242)
Is this a known bug?
Interesting, I’ve not even managed to get that far on my site. It could be however that there’s another js error earlier up on the page…
Actually, I spoke too soon, but maybe you have a similar issue.
My threaded replies are not working due to a plugin conflict.
I discovered this by disabling plugins one by one, and testing threaded replies after each disable.
My conflict is with Toolset Layouts.
Perhaps yours is a plugin conflict, as well.
Hmmm possible I will test it out although there aren’t many plugins to disable! Did all the replies you’d made instantly thread themselves once you’d disabled the plugin or did you have to keep creating new threaded replies?
Hey there … I got mine working.
There is a file in the bbPress plugin folder
plugins > bbpress > templates > default > js > reply.js
On line 18, there is a line of code that is throwing a JavaScript error every time the “reply” link is clicked.
reply.parentNode.insertBefore(respond);
I basically commented this line of code out, and threaded replies are working again.
I have no idea if this line is needed, but it got rid of the error, and there are no new errors to speak of.
I wish a plugin developer would chime in here, but that doesn’t seem likely.
I hope this helps you.
If anyone else reading this know what this line does, and why it was causing the error, please let us know.
Actually, I figured out what line 18 does.
I made a change. Instead of commenting it out, I edited it to be:
reply.parentNode.insertBefore(respond, reply);
I added “reply” as the second argument being called.
After I did this, the response box, where you put your comment now moves to right under the post where you click reply.
Check it out, and let me know if oyu get it working.
Cheers!
Thanks! Will give it a go on my site later.
One last thing … so the change doesn’t get overwritten when you update the plugin, copy the entire ‘reply.js’ file, and put that copy in a ‘js’ folder in your theme’s main folder …. so if you’re using TwentySeventeen, as an example, the path would be ‘Themes/TwentySeventeen/js/reply.js’.
Then you’ll be safe.
I wish a plugin developer would chime in here, but that doesn’t seem likely.
I’m not sure how often they visit, but looks like you done some great stuff here.
I’ve made a note of this thread and I’ll post a trac ticket (bug report) shortly
Can you just confirm what version of bbpress you are using, and if not bbPress 2.6 Release Candidate 3, can you just check that the code is not improved in this – you’ll do this much faster than me.
No luck I’m afraid
Robin,
I am using Version 2.5.13, directly downloaded from the WP Repository. There doesn’t seem to be an update pushed to the repository yet. I usually don’t install non-production versions on a production website.
dwinn, I’m sorry to hear that you are having a different issue than I am having. Can you please check the console in Chrome Dev Tools to see if you are getting any errors either before, or when you click the ‘reply’ link?
Thanks!
Robin,
As far as Release 2.6 Candidate 3, the line of code in reply.js on/near line 18 is still the same:
reply.parentNode.appendChild(respond);
I changed it to:
reply.parentNode.appendChild(respond, reply);
Which seemed to do the trick.
However, I am unsure what else would be affected by this change, as I am unfamiliar with the core code of this plugin.
Please submit any or all of my comments about this here. My issue is fixed, and I hope it helps others.
Cheers!
dwinn,
I just checked your website, and you have an error in the console:
Uncaught ReferenceError: jQuery is not defined at (index):17
jQuery not being define can have very negative effects on a website.
Hope this helps!
jQuery is defined but for some reason some script has been inserted into the head of the page and is loaded before jQuery. Is it possible to call jquery in the first line of the header do you know?
I’d say this is an appropriate article on how to properly enqueue jQuery:
Also, if you know what script is inserting itself above jQuery, and you have control over how it is enqueued, make sure you enqueue to the footer:
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
Make sure your ‘$in_footer’ is TRUE:
wp_enqueue_script('script-handle', plugins_url('js/script.js' , __FILE__ ),'','1.0',true);
Thanks for this although I am well aware of how to enqueue jQuery scripts. The issues is that I don’t know what script it is that’s being inserted that early on – I will have to test it out some more.
I just try latest version of BBPress, and this problem exist. Is there any fix coming? Codes above didn’t work for me.
ok, so
1. Save the attached code to your pc, as a new file called reply.js
2. Create a directory on your theme called ‘js’, and copy the renamed file reply.js to it, so that you end up with wp-content/themes/%my-theme%/js/reply.jswhere %my-theme% is the name of your theme
Let me know if this works
addReply = { moveForm : function(replyId, parentId, respondId, postId) { var t = this, div, reply = t.I(replyId), respond = t.I(respondId), cancel = t.I('bbp-cancel-reply-to-link'), parent = t.I('bbp_reply_to'), post = t.I('bbp_topic_id'); if ( ! reply || ! respond || ! cancel || ! parent ) return; t.respondId = respondId; postId = postId || false; if ( ! t.I('bbp-temp-form-div') ) { div = document.createElement('div'); div.id = 'bbp-temp-form-div'; div.style.display = 'none'; respond.parentNode.insertBefore(div, respond); } reply.parentNode.insertBefore(respond, reply); if ( post && postId ) post.value = postId; parent.value = parentId; cancel.style.display = ''; cancel.onclick = function() { var t = addReply, temp = t.I('bbp-temp-form-div'), respond = t.I(t.respondId); if ( ! temp || ! respond ) return; t.I('bbp_reply_to').value = '0'; temp.parentNode.insertBefore(respond, temp); temp.parentNode.removeChild(temp); this.style.display = 'none'; this.onclick = null; return false; } try { t.I('bbp_reply_content').focus(); } catch(e) { } return false; }, I : function(e) { tinymce.execCommand('mceFocus',false,'bbp_reply_content'); } }
I am still fairly new and finding my way around, but found your fix gets rid of the error.
However, the comments in this thread suggested that the reply comments box appears below the comment which is being replied to, which your code does not. Instead the comment box appears at the end of the thread.
Restoring I() in reply.js to “return document.getElementById(e);” (from “tinymce.execCommand(‘mceFocus’,false,’bbp_reply_content’);”) fixes that. I tried tinymce.execCommand(‘mceFocus’,false,e); which seemed to be more appropriate but that did not work either.
Hi ya,
bbPress newbie here.I’ve found a similar problem where if I click reply on a topic post, then it drops me down the page. In the Chrome console I see this error:
Uncaught ReferenceError: addReply is not defined
at HTMLAnchorElement.onclick (VM3866:1501)
———-
And then clicking on the “(VM3866:1501)” link gets this:return addReply.moveForm(‘post-369′,’369′,’new-reply-368′,’368’);
————–
I tried adding the above fix to the reply.js file, but that didn’t work.
But based on that error, I’m assuming that something else is removing that bit of the JavaScript…
Or there’s a scope problem?
Are you sure reply.js is being loaded by chrome? You should be able to see quickly enough under the “Sources” tab of the Developer Tools (Ctrl+Shift+I) – from where you uploaded the replacement reply.js. Possibly a permissions thing?
I am having this problem too. It looks like reply.js isn’t getting enqueued because bbp_is_single_topic is false.
/wp-content/plugins/bbpress/templates/default/bbpress-functions.php
if ( bbp_is_single_topic() ) {
…
// Hierarchical repliesif ( bbp_thread_replies() ) {
$scripts[‘bbpress-reply’] = array(
‘file’ => ‘js/reply.js’,
‘dependencies’ => array( ‘jquery’ )This should be bbpress functionality, but I’m unsure how to fix this. Also, I checked the permission, and it looks okay.
looks to me like bbpress-functions.php is not loading the topic.js nor reply.js when using a shortcode to load a topic.
I commented out this if and then the scripts load:
/*if ( bbp_is_single_topic() ) {*/
// Topic favorite/unsubscribe
$scripts[‘bbpress-topic’] = array(
‘file’ => ‘js/topic.js’,
‘dependencies’ => array( ‘jquery’ )
);// Hierarchical replies
if ( bbp_thread_replies() ) {
$scripts[‘bbpress-reply’] = array(
‘file’ => ‘js/reply.js’,
‘dependencies’ => array( ‘jquery’ )
);
}
/*}*/so similar to the above post it appears that bbp_is_single_topic() is returning false for some reason. I tested this without any other plugins and also with the latest development version and the scripts still do not load unless I comment out that if. I suppose this means these scripts get loaded all the time but everything seems to still work
Your change worked for me last week. Thanks for that!
Only changing the line 18 reply.js
reply.parentNode.appendChild(respond, reply);
I don’t know if there is a side effect on this but I think it’s not because for a week is working.
I’m using the version 2.5.14. I didn’t try to deactivate all my plugins to see if there’s a conflict.
- You must be logged in to reply to this topic.