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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:17:58+00:00 2026-06-07T23:17:58+00:00

I have a model foo in my rails app, and in the index page

  • 0

I have a model foo in my rails app, and in the index page all the foos are listed in a table. Each foo has 2 integer properties: quarto and jesolo.

enter image description here

I’m giving different ids to the html number fields, in the following way:

foo #1

1st field: foo1_quarto

2st field: foo1_jesolo

foo #2

1st field: foo2_quarto

2st field: foo2_jesolo

ecc…

At the moment I’m using the following ajax code (written in coffee script) to make the user input on foo1_quarto being reflected also in foo1_jesolo:

$("#foo1_quarto").keyup ->
    a = parseInt document.getElementById("foo_quarto").value
    $("#foo1_jesolo").val a

But now I need to serialize this. I don’t know in advance how many food there will be, and I’d like to have a piece of ajax code that covers all of them

  • 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-07T23:18:01+00:00Added an answer on June 7, 2026 at 11:18 pm

    Not sure I understand your english, but couldn’t you collect all the inputs and serialize them like so ?

    $("input").serialize ->
    

    So in an AJAX call it would be :

    $.ajax '/',
        type: 'POST'
        data: $("#my_form input").serialize ->
        dataType: 'script' error: (jqXHR, textStatus, errorThrown) ->
            $('body').append "AJAX Error: #{textStatus}"
        success: (data, textStatus, jqXHR) ->
            $('body').append "Successful AJAX call: #{data}"
    

    Also, I’d personally stray away from using unique ID’s for your keyup method. In this way, you wouldn’t have to write the same thing for every single item.

    Instead I would make each one share a common class .foo_input and/or .other_foo, and write it like so :

    $(".foo_input").keyup ->
        $(this).sibling(".other_foo").val $(this).value
    

    But ideally, you would use one class and use jQuery selectors to get to it. Not sure how your HTML is set up.

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

Sidebar

Related Questions

In my Ruby on Rails app, I have a User table and a Foo
Given that I have a Foo model w/ the standard Rails timestamp columns what
I have model Foo which has field bar. The bar field should be unique,
Let's say I have a model foo, and my model has a publish! method
In a Rails 3.2 app I have a Model with a text column :data
Apologies for the difficult title, but I essentially have a model Foo that has
In my rails app I have a models/foo.rb and models/foo/exceptions.rb : class Foo include
Simple Rails question. I have a model Foo which looks like this: class Foo
In my Rails app, I have a model called Photo and a PhotosController. As
I have a model in my Rails app that uses the :class_name attribute for

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.