How can I catch a change event from an HTML text field when a user clicks on a link after editing?
Posted
by Eric the Red
on Stack Overflow
See other posts from Stack Overflow
or by Eric the Red
Published on 2010-05-17T21:58:29Z
Indexed on
2010/05/17
22:00 UTC
Read the original article
Hit count: 207
Our webapp has a form with fields and values that change depending on values entered. Each time there is a change event on one of the form elements, we use an expensive AJAX call to update other elements on the page.
This works great for selects, radio buttons and checkboxes. The issue comes in when a user adds content to a text field, and then clicks a link without taking the focus from the text field. The browser moves to a new page, and the contents of the text field are never saved. Is there an easy way to code around this? The AJAX call is too expensive to call with each key press.
Here's an example of my Prototype code at the moment:
$$('.productOption input.text').invoke('observe', 'change', saveChangeEvent);
© Stack Overflow or respective owner