AJAX Form doesn't load for first comment on node.

Created on 23 October 2017, almost 8 years ago
Updated 24 June 2025, about 2 months ago

If there are no comments on a node(and therefore the comments section is not printed), clicking the "add new comment" link will not load the ajax comment form and causes an error in the console.

ajaxComments-ScrollToElementError: TypeError ajax_comments.js:10:7

The only way to create the first comment on the node is by selecting the option "Show reply form on the same page as comments" under content type settings. Ajax comment will then function properly. It does not make sense that this would be a requirement of ajax functionality for commenting.

When clicking the "add new comment" link on the node itself the AJAX form should load under the node just like it does when using the reply link on a comment entity.

Depending on the comments section to pre-exist via the "Show reply form on the same page as comments" setting also causes a conflict with advanced forum. This is because advanced forum's node reply and quick reply buttons depend on the comment form having an ID of #comment-form, as noted in this issue , which Ajax comments removes.

Please load the comment form when it does not already exist so that we can use ajax comments for generating the first comment of a node.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada TheDukeofURL

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • You've identified a key issue with the ajax_comments module: it errors out when trying to "Add new comment" on a node with no existing comments because its JavaScript expects the comment form or section to already be on the page. Forcing "Show reply form on the same page as comments" fixes this by pre-rendering the form, but causes conflicts with modules yourtexasbenefits like Advanced Forum that expect the #comment-form ID. The ideal solution is for ajax_comments to dynamically load the comment form via AJAX when it's not present, making it more robust and eliminating the need for the workaround.

Production build 0.71.5 2024