Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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();
});
share|improve this answer
add comment

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.

share|improve this answer
    
Very clever. Thank-you for showing me this. How would I have figured this out on my own? –  mrtsherman Mar 23 '11 at 22:07
    
I'm going to end up marking my own solution as correct because I think it is easier to implement. +1 to you though for what seems like a very appropriate solution(s). –  mrtsherman Mar 24 '11 at 19:08
    
@mrtsherman: No problem, you should accept the answer that helped you solve the problem - even if you found the answer yourself! And your solution is more complete, because you also handle the cancel event. –  Jan Fabry Mar 24 '11 at 19:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.