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 69797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:37:49+00:00 2026-05-10T19:37:49+00:00

Sorry, if this is a noobish question, but I’m just getting started with Rails

  • 0

Sorry, if this is a noobish question, but I’m just getting started with Rails and jQuery. I have the following scenario:

I have 3 classes: contacts, companies and contact_company_joins (ccj). For all three classes I created models, controller and views. Obviously, contacts and companies are connected via the join-table ccj (using has_many :through).

contacts <-> contact_company_joins <-> companies

In my contact’s ‘show’ view I want to display a table that lists all companies that the contact is connected to (and some additional info on the company itself e.g. phone-number). In my company’s view I want to do the same, but this time with the employees’ (contacts’) details. Each row of the table has the typical ‘delete’ link at the end, whose function I have now hooked up to one of my jQuery functions:

$('.edit_contact_join_delete').livequery('click', function() {     var $deleteButton = $(this);     var answer = confirm('Sure?');     var dataloc = '&_method=delete';     if (answer) {      $.ajax({           type : 'POST',           url  : this.href,           data : dataloc,           success: function(result) {           }         });     }     return false;   }); 

In both views (contact and company), the delete action takes me to the destroy function of the ccj controller. What I want to do now is to update or rerender the table of the individual site (contact or company) that is calling the delete function, but ONLY the part of the table. I guess I must implement it in the ‘success’ function above? But then again, even if I return something from the ccj’s controller (a rendered partial?)…that would be the same for both contact and company view, right? How can I make sure that after my Ajax call to destroy the ccj object, I get a fresh DOM object for my contact’s view (which would be a new company table), but also get a fresh contacts table when I do the Ajax call from my company view?

Hope this all makes sense 🙂

Regards,

Sebastian

  • 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. 2026-05-10T19:37:50+00:00Added an answer on May 10, 2026 at 7:37 pm

    All you need is for the delete action to return a success or failure (even just true or false will do), then your javascript can deal with either response.

    If a failure then return a message saying so, if a success and the relationship deleted, you could find the <tr> parent of the delete link that you clicked and fade the row out, eventually deleting it from the page. For example (given that your controller returns true if the delete is successful and false otherwise):

    $('.edit_contact_join_delete').livequery('click', function() {     var $deleteButton = $(this);     var answer = confirm('Sure?');     var dataloc = '&_method=delete';     if (answer) {      $.ajax({           type : 'POST',           url  : this.href,           data : dataloc,           success: function(result) {             if (result) {               // handle successful delete               $deleteButton.parent('tr').fadeOut().remove()             } else {               // handle failed delete               alert('Delete failed');             }           }          });     }     return false;      }); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for the noobish question here, but I am just learning C++ and I
Ok sorry this might seem like a dumb question but I cannot figure this
Sorry for this not being a real question, but Sometime back i remember seeing
Sorry if this sounds like a really stupid question, but I need to make
Sorry if this is a comp-sci 101 question. I'm just unsure if I'm missing
Sorry I couldn't find the best heading for this question. Following is my requirement.
Sorry for so noobish question but how can I do it with C++? I
Sorry if this is a little off-topic for regular stackoverflow questions, but we're tearing
I'm sorry for this very newbish question, I'm not much given into web development.
Sorry, I thought this was an inheritance question: it was an ArrayList question all

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.