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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:47:04+00:00 2026-05-20T23:47:04+00:00

So I have an autocomplete field where a user can select an existing or

  • 0

So I have an autocomplete field where a user can select an existing or create a new tag. If a user creates a new tag, he presses the form button, and it sends a POST request to the update action in the videos controller which processes the request as AJAX, and the tag gets displayed above the field.

Now, the problem is when a user selects a tag from the suggestion list. By default, the jQuery UI autocomplete plugin appends the selected element inside the field, and then the user has to press the form button. However, I want to save the user some effort by automatically adding the tag right when it’s picked from the suggested list. Therefore, I have this code in my application.js file:

select: function(event, ui) {
           var url = $('.edit_video').attr('action');
           var val = ui.item.topic.name;
           $.ajax({type:"PUT", url:url, data:{video:{topic_names:val}}});
           return false;
        }

That successfully sends a PUT request to the update action when an element is selected from the list. However, the request is NOT processed as AJAX. The tag is successfully added, but only after a page refresh. I want the request to be processed as AJAX. How can I do this?

I’m guessing that the problem has to do with the fact that when you press the form button, the :remote => true option tells rails to look for format.js (which I have in my update action), but when the button is not pressed, and an element is selected from the list, Rails does not know to look for JS. How do I let it know?

  • 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-20T23:47:05+00:00Added an answer on May 20, 2026 at 11:47 pm

    I’m assuming here that by something not being processed as AJAX that you mean that it’s not rendering the view.js.erb file, but rather the view.html.erb file instead. You can fix this by forcing the format of the URL in your JS like this:

    var url = $('.edit_video').attr('action') + ".js";
    

    That would then send it to the right format for your action.

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

Sidebar

Related Questions

No related questions found

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.