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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:59:45+00:00 2026-06-03T14:59:45+00:00

Railscast 88 revised The coffeescript in this railscast specifies the IDs of the html

  • 0

Railscast 88 revised

The coffeescript in this railscast specifies the IDs of the html select option lists:

  states = $('#person_state_id').html()

However, I am using nested forms, which generate new form fields, and their IDs, dynamically. For instance:

book_extents_attributes_new_extents_extent_value_input

or

book_measurements_attributes_2_measure_type_input

How do I generate those IDs on the fly?

  • 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-03T14:59:46+00:00Added an answer on June 3, 2026 at 2:59 pm

    A kind fellow helped me out: here’s a solution.

    #view partial for nested form fields, as per railscast.

    = javascript_include_tag 'simple_tooltip'
    .nested-fields
      = f.inputs :class => :data_table_format do
        = f.input :client_id,   :as => :hidden, :value => current_user.client_id
        = f.input :extent_value, :label => "Extent", :input_html => {:class => 'nested_narrow_input'}
        %li.select
          = f.collection_select :extent_type_id, ExtentUnit.order(:value), :id, :value, {include_blank: true}, {:class => 'nested_drop_down_one_of_two'}
        %li.select
          = f.grouped_collection_select :extent_unit_id, ExtentUnit.order(:value), :extent_types, :value, :id, :value, {include_blank: true}, {:class => 'nested_drop_down_two_of_two'}
        .links
          = link_to_remove_association image_tag("#{static_root}/cross.png", {:class => :cross}), f
    

    #application.js or somewhere in the asset pipeline

        $(document).ready(function(){
    
            $(".nested_drop_down_two_of_two").each(function(i,v){
                $(this).attr("data-content",$(this).html());
            });
            $(".nested_drop_down_one_of_two").live("change", function() {
    
                selected_type = $(this).find("option:selected").text();
                var content = $($(this).parent("li.select").next().find(".nested_drop_down_two_of_two").attr("data-content")).filter("[label='"+selected_type+"']").html()
                $(this).parent("li").next().find(".nested_drop_down_two_of_two").html(content);
                return true;
            });
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed the directions in Railscast #17 HABTM Checkboxes (revised) to get this code
I am using Rails 3.1 and have been using this railscast tutorial to implement
I'm using jquery_token_input after following Ryan Bates railscast #258 and this is the code
I am using Rails 3.0.7 and I am trying to follow this Railscast: http://railscasts.com/episodes/182-cropping-images
attempting to use this railscast as a guide: http://railscasts.com/episodes/197-nested-model-form-part-2?view=asciicast and running into this error:
I am using Railscast Episode # 250 to implement authentication from scratch. However, now
I'm following part of this Railscast and trying to load a static file using
I've been following RailsCast 197 to try this nested models/forms and have cracked my
Using this railscast http://railscasts.com/episodes/127-rake-in-background?autoplay=true as an example/inspiration (i.e. I'm not trying to implement the
I followed RailsCasts authentication from scratch (http://railscasts.com/episodes/250-authentication-from-scratch-revised) using the bcrypt-ruby gem and have the

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.