Topic: observe_field, how can i change the observed event ?

Hi all,

I want to observe a text_field for the focus event, but i don't understand something.

Here's a simple code :

<%= text_field_tag :myname, "" %>
<%= observe_field( "myname", {:function => "alert('event catched')", :on => 'focus'}) %>

Generated code is :
<input id="myname" name="myname" type="text" value="" />
<script type="text/javascript">
//<![CDATA[
new Form.Element.EventObserver('myname', function(element, value) {alert('event catched')}, 'focus')
//]]>
</script>

The problem is that the last parameter ('focus') seems to be ignored by prototype. I tried to debug this with firebug, and prototype never user this last argument.
At the end of the callstack, prototype assign the callback to an event using this code :
    if (element.type) {
      switch (element.type.toLowerCase()) {
        case 'checkbox':
        case 'radio':
          Event.observe(element, 'click', this.onElementEvent.bind(this));
          break;
        default:
          Event.observe(element, 'change', this.onElementEvent.bind(this));
          break;
      }
    }

I miss something ? My prototype version isn't correct (1.6.0.3) ?

Cheers.

Gilles.