Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:52:07+00:00 2026-06-01T15:52:07+00:00

Here is the code I’m currently using: $.ajax({ success: function(){ $(‘.post_container’).append(‘test <br />’); }

  • 0

Here is the code I’m currently using:

$.ajax({
    success: function(){
        $('.post_container').append('test <br />');
    }
});
<% sleep 1 %>

It is similar to the code I used for my single main micropost form but with this there are several comments that use the same class and so test is being applied to all post_containers rather than the one the post was just made to. “test” text will eventually be replaced with the div that holds the actual comments users post.

Normally I would use “this” but that won’t work here.

HTML:

<div class="post_content">
    <div class="post_container">
        <div class="userNameFontStyle">
            <%= link_to current_users_username.capitalize, current_users_username %> -
            <div class="post_time">
                <%= time_ago_in_words(m.created_at) %> ago.
            </div>
        </div>  
        <%=  simple_format h(m.content) %>
    </div>
    <% if m.comments.any? %>
    <% comments(m.id).each do |comment| %>
    <div class="comment_container">
        <%= link_to image_tag(default_photo_for_commenter(comment), :class => "commenter_photo"), commenter(comment.user_id).username %>
        <div class="commenter_content">
            <div class="userNameFontStyle">
                <%= link_to commenter(comment.user_id).username.capitalize, commenter(comment.user_id).username %> - <%=  simple_format h(comment.content) %>
            </div>
        </div>
        <div class="comment_post_time">
            <%= time_ago_in_words(comment.created_at) %> ago.
        </div>
    </div>
    <% end %>
    <% end %>
    <% if logged_in? %>
    <%= form_for @comment, :remote => true do |f| %>
    <%= f.hidden_field :user_id, :value => current_user.id %>
    <%= f.hidden_field :micropost_id, :value => m.id %>
    <%= f.text_area :content, :placeholder => 'Post a comment...', :class => "comment_box", :rows => 0, :columns => 0 %>
    <div class="commentButtons">         
        <%= f.submit 'Post it', :class => "commentButton" %>
        <div class="cancelButton">
            Cancel
        </div>
    </div>   
    <% end %>
    <% end %>
    </div>
</div>

How would I deal with this?

Kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:52:08+00:00Added an answer on June 1, 2026 at 3:52 pm

    This is how I had to do it in the end.

    .new_comment is my form id

    $('.new_comment').on('ajax:success', function(){
        $(this).parent('.post_content').find('.comment_container:last').after("<BR />TEST <BR />");
    
    });
    
    <% sleep 1 %>
    

    The only issue now is identifying the actual comment_container for the post just made.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int
Why is substringFromIndex not working for my NSMutableString ? Here code similar to what
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from a tutorial in A Byte of Python: import sys filename
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is code example class A{ int i; public: A(int i) : i(i) {}
enter code here I've created a simple code for mount virtual disk into system
enter code here I have a table on SQL server 2005 with bigint primary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.