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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:39:20+00:00 2026-05-13T20:39:20+00:00

I need to use JQuery in order to detect the changes on a text

  • 0

I need to use JQuery in order to detect the changes on a text file, so some ajax is invoked.

The trick is that I don’t really want to bind this action to the blur or keyup events; The former is too cumberstone for the user and the second is “too inmediate”: the user types new keys before the ajax call has been completed, so the user experience isn’t great (so the answer on this SO question does not apply on my case).

What I need is some code that checks whether the field value has changed, but periodically (i.e. every 0.5 seconds). I’d like to use the same code on several fields, calling different ajax functions, with different frequencies, so reuse is really a plus here.

On Rails I had observe_field (internally uses Prototype’s Form.Element.observer, I think) that did just this. How can I accomplish the equivalent thing on JQuery?

  • 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-13T20:39:20+00:00Added an answer on May 13, 2026 at 8:39 pm

    I ended up rolling my own jquery plugin.

    It is (loosely) based on Mic’s implementation.

    Created a github project for it:

    http://github.com/splendeo/jquery.observe_field

    Main differences with Mic are:

    • I’m using jQuery’s methods instead of native ones in a couple places.
    • I don’t activate/deactivate detection onblur and onfocus. This way I can track changes done with code (rails’ observe_field does this, and I wanted to mimic it)
    • I reset the timer on each onkeyup. I needed this in order to play nicely with mobile devices, such as the iphone.

    Quick snippet:

    $(function() {
      // Executes a callback detecting changes with a frequency of 1 second
      $("#item1").observe_field(1, function( ) {
        alert('Change observed! new value: ' + this.value );
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.