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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:43:50+00:00 2026-05-31T21:43:50+00:00

I`m trying to add autocomplete to a field that is included in a partial

  • 0

I`m trying to add autocomplete to a field that is included in a partial view in a Rails 3 app.

I can`t tell JQuery to look for it via form name, since a random attribute is generated every time the field is rendered.

Here’s rundown of the code:

cardio_exercises.js.coffee

jQuery ->
    $('input.Cardio').autocomplete
      source: ['Elliptical trainer','Stair stepper (Stairmaster)','Stationary or recumbent bike','Jacob`s ladder','Arm ergometer (arm cycle)','Rowing machine','Treadmill walking','Treadmill running','Kettlebells','Interval training','Box jumps','Step ups','Plyometrics','Cycling','Jogging','Running','Power walking','Swimming','Water jogging/running','Bleacher running','Spinning','Step aerobics','Walking the dog','Playing with your dog','Taking the stairs','Jumping jacks']

In the partial I added a class of Cardio to the input field:

_cardio_exercise_fields.html.erb

<table>
<tr>
  <td>
    <b>Exercise Name</b><br>
    <%= f.text_field :exercise_name, :class => 'Cardio' %></td>
  <td>
    <b>Duration</b><br>
    <%= f.text_field :duration %> minutes   
  </td>
</table>

I have no clue about JS/jQuery so I would appriaciate any advice on the matter.

I know that it works (autocomplete) in normal views, just not in the partial in trying to implement it in.

  • 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-31T21:43:52+00:00Added an answer on May 31, 2026 at 9:43 pm

    jQuery works normally in Rails3, I mean, once the page is rendered,

    $('input.Cardio')   // =>  will get a result:   [input.Cardio]
    

    I suggest you install the firebug and watch the error message from its console.
    ( or developer tool in chrome & safari)

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

Sidebar

Related Questions

Trying to add a blank sample app for a rails tutorial to GitHub, but
Currently I'm trying to add on to the auto-complete module for jquery that is
Given a straightforward jQuery Autocomplete, I'm trying to figure out how to dynamically add
I'm trying to use jquery autocomplete on a text field to allow users to
I'm trying to use rails3-jquery-autocomplete gem on OSX 10.7, Rails 3.1.0, Ruby 1.9.2-p290 I
i am trying to do an autocomplete feature in rails using the jquery ui
I'm trying to add the selected value from the autocomplete search box to my
I am trying to add in a class with the name of autocomplete into
Trying to add email notification to my app in the cleanest way possible. When
I'm trying to create a greasemonkey script (for Opera) to add autocomplete to input

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.