javascript - How can I catch a change event from an HTML text field when a user clicks on a link after editing? -


Our webpage has a form with fields and prices that change based on values. 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 selection, radio buttons and checkboxes. This issue comes when a user adds content to a text field, and then clicks on a link without focusing from the text field. is. The browser goes to a new page, and the content of the text field is not saved. Is there an easy way to code around this?

An example of my prototype code at the moment is:

  $$ ('. ProductOption input.text') .invec ('inspection', 'change', saveChangeEvent );  

Have you hooked to the event of the window? Here is an example of AC / P jQuery. Usage ()

  $ (window) Check the call to save the data to unload (function () {var input = $ ("# MyInput"); // text field if (input.length & gt; 0) // // Ajax, make sure that async: Incorrect Ajax call is set to.}});  

With this, you can work by making each key press, if you leave the page.


Comments