Skip to:
Content
Pages
Categories
Search
Top
Bottom

Nested / Threaded Replies not working in Chrome

  • @expectancy

    Participant

    Hello,

    When replying to forum replies (nested/threaded replies) everything works as it should in Internet Explorer, but in Chrome, instead of creating a nested reply, the user is taken to the general topic-reply form. The users think it will be a nested reply, and are of course frustrated when it ends up at the bottom of the list.

    In IE, no console errors are generated. Here is the error generated in Chrome when the REPLY button is clicked:

    Uncaught TypeError: Failed to execute ‘insertBefore’ on ‘Node’: 2 arguments required, but only 1 present.
    addReply.moveForm @ reply.js:18
    onclick @ (index):406

    Wordpress version 4.3.1
    X-Theme version: 4.1.0
    bbPress version: 2.5.8

    I have also tried other versions of the bbPress plugin with no success.

    Thanks!

    <imc src=”http://i.imgur.com/8GDJNNy.jpg”&gt;
    <imc src=”http://i.imgur.com/TIl1xpw.jpg”&gt;

Viewing 11 replies - 1 through 11 (of 11 total)
  • @maketheest

    Participant

    I have the same issue like above. anyone can help us ?

    @kineta

    Participant

    This bug isn’t just in Chrome. It’s actually because TinyMce editor doesn’t like being moved around the DOM, which is what the the function in bbPress is trying to do – tying to move the editor under the post you’re replying to.

    I wish this bug would get fixed, but in the meantime you can overwrite the javascript function in a .js file in your theme. This is what I did – remove the editor before moving the containing element, then reinitialize it. Works well for me.

    FYI: in case you don’t know javascript well – this needs to be inside jquery $(document).ready()

    // overwrite bbPress's broken function that moves the reply form under the replied to post in threaded topics
    	
    	addReply = {
    		moveForm : function(replyId, parentId, respondId, postId) {
    						
    			tinymce.remove('#bbp_reply_content');
    			// it can't possibly be this easy:
    			$('#post-container-'+parentId).after($('#'+respondId)); 
    			
    			tinyMCE.init({   
    				selector: 'textarea', 
    				plugins: 'hr, wplink, textcolor, paste, image, media, wpemoji, emoticons, charmap, fullscreen',
    				forced_root_block : "",
    				menubar: false,
    				toolbar1: 'styleselect,bold,italic,underline,strikethrough,blockquote,bullist,numlist,alignleft,aligncenter,alignright,fullscreen',
    				toolbar2: 'fontsizeselect,forecolor,outdent,indent,hr,charmap,emoticons,image,media,link,unlink,wp_help'
    			  });
    			
    			// write the correct reply-to id to the hidden field that stores it
    			// this prevents the wrong id inserted because we're returing false at the end of the function.
    			$('input#bbp_reply_to').val(parentId)
    			
    			// return false to prevent page reload, losing all the work.
    			return false; 
    		}
    	}

    @maketheest

    Participant

    @Kineta
    I have added your code on custom.js on my theme but error still appeared : Uncaught TypeError: Failed to execute ‘insertBefore’ on ‘Node’: 2 arguments required, but only 1 present.

    @kineta

    Participant

    @maketheest – sounds like the error coming from the bbPress code, which uses “insertBefore”. Make sure the overwrite is being called *after* the bbPress javascript. Or try clearing your browser cache. Also make sure all the divs & textarea is named the same as my js – or change accordingly.

    The heart of it is that the TinyMCE editor doesn’t like being moved around in the DOM, which is what the bbPress function is trying to do. You need to remove it first, then re-initialize it after moving the container. The last piece is to put the parentId, which is passed by the function, into the hidden field (should have the id of bbp_reply_to) that accompanies the editor.

    @expectancy

    Participant

    For anyone that hasn’t solved this yet, it’s actually a very easy and quick fix!

    In the W3 spec (http://www.w3.org/TR/dom/), the “insertBefore” method requires 2 arguments. The second can be null, but it is still required. It looks like IE doesn’t require the second argument (which is why it works in IE as is) while Chrome, Firefox, and Safari do.

    bbpress/templates/default/js/reply.js – line 18
    Added a null argument as the second argument on “insertBefore”.

    Before Fix: reply.parentNode.insertBefore(respond);
    After Fix: reply.parentNode.insertBefore(respond, null);

    
    reply.parentNode.insertBefore(respond, null);
    if ( post && postId )
    	post.value = postId;
    parent.value = parentId;
    cancel.style.display = '';
    

    @r083r7

    Participant

    Same here… Nested / Threaded Replies not working

    @robkk

    Moderator

    I add create a ticket and include @expectancy’s patch. Hopefully this will be included in the next version of bbPress.

    @robkk

    Moderator

    @netweb

    Keymaster

    Thanks, Ill take a look at this shortly.

    @netweb

    Keymaster

    @mrtylershin31

    Participant

    holy shit thanks … I know jack shit about coding but I sure love what that ‘null’ did

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.
Skip to toolbar