Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do textarea change events not get triggered?

I'm relying on the change event being triggered whenever the contents of the textarea changes. According to the jquery docs, this doesn't get triggered until the textarea loses focus. Under what circumstances could the event not be triggered? Would clsoing a page, going back, clicking on a link, etc, always cause the textarea to lose focus and be fired?

Or to put it another way, is it possible to leave a page without a focusses textarea losing input?

like image 270
Paul Biggar Avatar asked Jan 19 '12 06:01

Paul Biggar


1 Answers

With differents tests, the change event is not triggered when:

  • the user clicks on any button of the browser (back button, refresh, home button...) (Chrome, Firefox amd Opera on Linux but triggered when click on adress bar)
  • the user uses shortcuts (f5, ctrl+u...) (tested on Chrome + Firefox + Opera).

You can test an example here: http://jsfiddle.net/Atinux/S6TkP/

So I recommand you to use in addition keyUp and keyDown events on your input and textarea forms.

like image 64
Atinux Avatar answered Oct 26 '22 22:10

Atinux