0

I want to add autosize.js to the form textarea (#comment) but if comment-reply.js is enabled no other javascript in the comments form works. Any idea why is this happening?

//Auto resise textarea
autosize( $("#comment") );

No errors in the console and works fine when comment-reply.js isn't enabled.

I also tried a simple test with a click event and it doesn't work also.

$("#comment").on( "click", function() {
    console.log("click");
});
10
  • Any errors in the JS console?
    – RRikesh
    Commented Mar 16, 2016 at 8:41
  • @RRikesh no errors
    – UXTE
    Commented Mar 16, 2016 at 8:46
  • 1
    Downvoted as "I have some code that doesn't work, but I am not going to tell you what is it" type of questions get boring very fast Commented Mar 16, 2016 at 8:47
  • 1
    @mmm added more information, does it help?
    – UXTE
    Commented Mar 16, 2016 at 9:09
  • 1
    now you starting to get there, pity a downvote was needed :(. are you sure your textarea has a "comment" id? have you removed the comment-reply.js and actually saw that your click script works after that? Commented Mar 16, 2016 at 9:10

1 Answer 1

0

I found the cuplrit and has nothing to do with comment-reply.js.

I was targeting my javascript based on which template and of course the javascript wasn't loading.

if( $("body").hasClass("page") ){ ...

Needed to add this:

if( $("body").hasClass("page") || $("body").hasClass("single") ){ ...
2
  • happens to all of us. The take away should be that when you ask a question here make a minimal "prof of bug" snippet to post here. This problem would have been spotted by you while doing that, or spotted by someone else almost immediately. Commented Mar 16, 2016 at 9:55
  • @MarkKaplun point taken!
    – UXTE
    Commented Mar 16, 2016 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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