# Field\_observer :on

**URL:** <https://www.ruby-forum.com/t/field-observer-on/122251>\
**Category:** Rails\
**Created:** [December 5, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/field-observer-on/122251 "2007-12-05T22:37:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![linojon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/b3f665/32.png) [@linojon](https://www.ruby-forum.com/u/linojon)\
**Post date:** [December 5, 2007, 10:37pm UTC](https://www.ruby-forum.com/t/field-observer-on/122251/1 "2007-12-05T22:37:39Z")

</div>

Hi,  
I need a prototype/javascript guru to take a peek at this.

There’s been discussions about prototype.js missing full support for  
the :on parameter to field\_observer  
eg this is ignored, and always defaults to on “change”, whether you  
use “focus”, “keyup” , “blur” whatever

\<%= observe\_field ‘foo’, :on =\> “focus”, :function =\> ‘Element.show  
(“foobar”)’ %\>

here’s some background:  
[http://dev.rubyonrails.org/ticket/9003](http://dev.rubyonrails.org/ticket/9003)  
[http://groups.google.com/group/rubyonrails-talk/browse\_thread/thread/](http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/)  
b297e6e10c1989fc?hl=en (discusses “blur”)  
[http://jonathan.tron.name/articles/2006/07/21/working-on-forms-with-](http://jonathan.tron.name/articles/2006/07/21/working-on-forms-with-)  
prototype (specific to “focus”)  
[http://joshhuckabee.com/rails-observe-field-function-and](http://joshhuckabee.com/rails-observe-field-function-and) (general  
solution)

The joshhuckabee article seems the best generalized solution, gives a  
patch to prototype.js

but seems out of date w/r/t Rails 2.0 prototype.js When I add the  
patch, FireBug goes into an infinite loop adding errors:

Form.Element.getValue is not a function  
return Form.Element.getValue(this.element);

It’s probably a simple fix to get it to work again. But I dont know  
js that well…

tia
