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

  • SEARCH
  • Home
  • 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 6234235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:26:54+00:00 2026-05-24T10:26:54+00:00

every time i use the remove method when deleting object via javascripts it does

  • 0

every time i use the remove method when deleting object via javascripts it does not work.

my destroy.js code is as follows.

$("#<%= dom_id(@comment) %>").remove();
    $('#comment-count-<%= @parent.id %>').html("<%= pluralize(@parent.comments.count,'comment')%>");

the pluralize works just fine

my _comment.html.erb is as follows

    <%= div_for comment do %>
<% if comment.user.profile.icon.exists? %>
     <%= image_tag comment.user.profile.icon.url(:small), :alt => comment.user.name, :class => "avatar tip", :title => comment.user.name %>
   <% else %>
   <%= image_tag comment.user.gender == 'Female' ? 'missing_woman.png' : 'missing_thumb.png', :alt => comment.user.name, :class => "avatar tip", :title => comment.user.name %>
   <% end %>
  <div class="comment-container">
     <span><%= link_to comment.user.name, comment.user.profile, :class => "profile-link-small" %></span> <%= comment.comment%>
   <div><span style="color:#888;"><%= formatted_time(comment.created_at) %></span> &ndash;&ndash; <span class="rank"><%= comment.user.level %></span>
    <% if can? :update, comment%> |
<span class="del"><%= link_to "Delete", comment, :confirm => "Are you sure you want to delete this comment?", :method => :delete, :remote => true %></span>
  <% else %>
        <span class="dialog_link">Delete</span>
  <% end %>
     </div>
  </div>
  <div class="clear"></div>
<% end %>

It use to work before but after i updated to rails rc5 it storped

  • 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-05-24T10:26:54+00:00Added an answer on May 24, 2026 at 10:26 am

    Your jQuery says this:

    $("#<%= dom_id(@comment) %>").remove();
    //-------------^
    

    But your ERB says this:

    <%= div_for comment do %>
    

    Your div_for should produce HTML something like this:

    <div id="comment_11">
        <!-- ... -->
    <div>
    

    Assuming that comment is a Comment object with id 11. Then dom_id on the same comment would produce comment_11 and that’s all good.

    However, you’re using @comment (an instance variable) to generate the DOM ID for the jQuery remove call but the local variable comment for the HTML. I’d guess that comment is the right one and you’re feeding a nil to dom_id, the result is that the IDs don’t match and your jQuery does nothing useful.

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

Sidebar

Related Questions

Should I use textbox.text.Trim() function every time when I insert any data from web
Every time i pass some parameters to a JavasScript or jQuery functon, i use
I use VS 2005 and VSS 2005. Every time I close VS I get
I use ssh-agent with password-protected keys on Linux. Every time I log into a
I know how to use tags in subversion. I create a tag every time
Do bubble sorts have any real world use? Every time I see one mentioned,
OK I love Python's zip() function. Use it all the time, it's brilliant. Every
I have a warning MyAnnotation does not implement the MKAnnotation protocol everytime I use
Is it ever OK to use Environment.TickCount to calculate time spans? int start =
I can't really ever think of a time when I would use git merge

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.