Hide reply button after moveForm is called

When user clicks on Reply button for a specific comment, how can I then hide the reply button under said comment? Do I have any access to the javascript onclick function that it calls?

Related posts

Leave a Reply

2 comments

  1. Ended up using jQuery to solve this. The form moves around using javascript anyways so it doesn’t break anything for users with js turned off.

    //when reply button is clicked hide it
    $(".comment-reply-link").click( function() {
        $(this).hide();
    });
    
        //when cancel button is clicked reshow reply button
    $("#cancel-comment-reply-link").click( function() {
        $(".comment-reply-link").show();
    });
    
  2. You can “wrap” the function by renaming it and defining your own function with the same name, that calls the renamed function. The “cancel” handler is internal, so you can’t access that.

    var oldAddComment = addComment;
    addComment = {
        moveForm: function(commId, parentId, respondId, postId) {
            var retVal = oldAddComment.moveForm(commId, parentId, respondId, postId);
            // Your code to hide the link here
            return retVal;
        }
    };
    

    You could also unregister the comment-reply Javascript, and register your own version. Or you can hook up extra handlers to the click event, with plain Javascript or with jQuery, as you have done.