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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:09:11+00:00 2026-05-23T07:09:11+00:00

I have a form_tag that submits a user’s search remotely to a Rails controller

  • 0

I have a form_tag that submits a user’s search remotely to a Rails controller method, which returns the results in JS format.

How can I automatically submit this form:

  1. When a user has entered in at least 2 characters
  2. When the user has paused for at least 1 second?
  • 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-23T07:09:12+00:00Added an answer on May 23, 2026 at 7:09 am

    Bind a keypress handler to the input using jQuery. In the callback, start a timer using setTimeout to submit the form after one second and keep a hold of the timer ID that setTimeout returns to you. If you have a non-null timer ID when your keypress callback is triggered, stop the timer with clearTimeout and set the timer ID to null; if they also have two characters at this point, then start the timer (again) and store the timer ID (again).

    So, you have a process in the keypress handler like this:

    1. Do I have a timer running?
      • If yes, clearTimeout, null the timer ID, and continue.
      • If no, then continue on.
    2. Do I have at least two characters?
      • If yes, start the timer with setTimeout and store the timer ID, the function attached to the timer would submit the form.
      • If no, then continue on.
    3. …
    4. Profit.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple search form in my Rails 3 app: <%= form_tag search_path,
I have a simple search form in my Rails 3 app: <%= form_tag search_path,
I have a form which uses reCAPTCHA. For some reason, when a user submits
I have a search page where user can submit queries that try to match
I have a form that is validated by js when the user submits it.
I'm trying to put together a form_tag that edits several Shift objects. I have
I have a simple, dynamic email form field. After the user submits their email,
I have a form where a user submits the description of an object (including
I have a page which submits a form on page load and redirects the
I have this form: in header of my website: <% form_tag request.path, :method =>

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.