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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:28:42+00:00 2026-05-30T19:28:42+00:00

In a rails 3 app using Jquery and JqueryUI, I’m rendering a partial to

  • 0

In a rails 3 app using Jquery and JqueryUI, I’m rendering a partial to display an accordion list of Items. I wish to call a controller action (let’s call it the Item#get_details action) to retrieve additional details via a web service about the Item upon the expansion of the appropriate accordion component.

The collection of items passed into the partial contains a description and an item number, as such:

render :partial => 'candidates' , :collection => @candidates
#Candidates is a list of hashes, each hash containing keys "Desc" and "id_number"

Each pass through the partial renders markup which jqueryUI renders as an accordion section, as below:

<h3><%= candidate[:desc] %>
<div id="candidate_details">
</div>

What is the best practice for binding a controller call to the <h3> which will retrieve details and populate the “candidate_details” div upon activation of the accordion item?

Thanks in advance.

  • 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-30T19:28:43+00:00Added an answer on May 30, 2026 at 7:28 pm

    First of all, I’d close that <h3>. Then use a data attribute on the <h3> to hold the id_number:

    <h3 data-id="<%= candidate[:id_number] %>"><%= candidate[:desc] %></h3>
    <div id="candidate_details"></div>
    

    Sounds like you want your accordion to start out with everything closed so you’d use something like this to bind the accordion:

    // Adjust these options to match your needs of course...
    $("#accordion").accordion({
        collapsible: true,
        autoHeight: false,
        active: false
    });
    

    The collapsible option allows all the panels to be closed at once, the autoHeight setting allows the panels to resize to fit their content, and the active setting starts them all out closed.

    Then, you could use one to bind a click handler to the <h3>s that will remove itself after its first activation. That click handler can dig out the data-id value and do an AJAX call to get the content for the corresponding <div>:

    $('#accordion').find('h3').one('click', function() {
        var id = $(this).data('id');
        $(this).next().load('/some/path/' + id);
    });
    

    Then your controller would use the id to look up the necessary content and send it back as a little blob of HTML.

    Demo of the jQuery-UI side: http://jsfiddle.net/ambiguous/BhJYv/

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

Sidebar

Related Questions

I'm using jquery-ui datepicker on a User DOB field in a Rails 3.2 app.
I'm using a jquery-ui datepicker in a Rails 3 app. The datepicker is currently
I am using the jQuery Form Plugin with my Rails app. I have a
I have a simple rails app the displays a list of items and i
I have jquery working on my Rails app using the gem 'jquery-rails' . I
I am using the JQuery Autocomplete UI with my rails app and it is
I want to create person objects in my rails app using a jquery ajax
I'm running a ruby on rails app, and I'm using jQuery to show some
Right now in my Rails 3 app I'm rendering partials using rjs in my
I am developing an app using Rails and jQuery. I would like to submit

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.