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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:48:27+00:00 2026-06-09T08:48:27+00:00

I have the following, very straight forward form. <%= form_for(@position) do |f| %> <div

  • 0

I have the following, very straight forward form.

<%= form_for(@position) do |f| %>
  <div class="field">
    <%= f.label :name %><br />
    <%= f.autocomplete_field :name, autocomplete_position_name_positions_path %>
  </div>
<% end %>

<script type="text/javascript" charset="utf-8">
  $('#name').bind('railsAutocomplete.select', function(event, data){
    /* Do something here */
    alert(data.item.id);
  });
</script>

Autocomplete all works nicely, but the alert(..) method is not called. I am very new to all this JavaScript stuff, so I’d be very thankful if somebody could point me into the right direction. Here’s what the compiled source looks like:

<form accept-charset="UTF-8" action="/positions" class="new_position" id="new_position" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="Sw+3CMXWmEPPYCNeCsAfNRX2DupZzZglMNSAnC4yDV4=" /></div>
  <div class="field">
    <label for="position_name">Name</label><br />
    <input data-autocomplete="/positions/autocomplete_position_name" id="position_name" name="position[name]" size="30" type="text" />
  </div>
</form>
<script type="text/javascript" charset="utf-8">
  $('#name').bind('railsAutocomplete.select', function(event, data){
    /* Do something here */
    alert(data.item.id);
  });
</script>

Thanks a lot, guys!

  • 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-09T08:48:29+00:00Added an answer on June 9, 2026 at 8:48 am

    Does your input have id “name”? Seems its id is “position_name”, not just “name”. Try to change $("#name") to $("#position_name").

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

Sidebar

Related Questions

I have a very straight forward class with mostly NSString type properties. In it,
Let's say I have the following, very simple block of code: <script> function hasVal(field)
I have the following very simple code snippet which is loaded from a separate
I have got the following very simple code: function init() { var articleTabs =
I have the following SQL statement which has a very bad performance: SELECT frmInstLastModifiedDate
I have the following line of code called very often: var configValue = System.Configuration.ConfigurationManager.AppSettings[ConfigValueKey];
I have the following function which works very well within a $(document).ready(function(){ $('.threadWrapper >
I have the following PHP code doing a very simple select into a table.
I have the following code in specman: var x := some.very.long.path.to.a.variable.in.another.struct; while (x ==
This is very weird. I have the following code: Assert.AreEqual(new DateTime(2000, 1, 1), DateTime.ParseExact(2000,

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.