Observe_field and on:focus

Hi,

I want to give suggestions(basically showing a hidden div) when somebody
clicks on the text box to write(I assumed this is what on:focus meant).

<%= observe_field :test_field, :function => “alert(‘Element on focus’)”,
:on => :focus %>

But surpisingly, alert is called when the value is changed and focus
moves onto something else…

Can somebody suggest? how to get this working?

Regards,
Sandeep G

<%= text_area ‘test’, ‘field’, “cols” => 60, “rows” => 4 , :onclick =>
“$(‘tips’).show();”, :onBlur => “$(‘tips’).hide();” %>

This did the trick; :slight_smile:

Sandeep G. wrote:

Hi,

I want to give suggestions(basically showing a hidden div) when somebody
clicks on the text box to write(I assumed this is what on:focus meant).

<%= observe_field :test_field, :function => “alert(‘Element on focus’)”,
:on => :focus %>

But surpisingly, alert is called when the value is changed and focus
moves onto something else…

Can somebody suggest? how to get this working?

Regards,
Sandeep G

<%= observe_field :test_field, :function => “alert(‘Element on focus’)”,
:on => :focus %>

observe_field is used to check whether any changes made to the
particular field…
Once u did any change in this particular field that alert was called.

Ratnavel S. wrote:

<%= observe_field :test_field, :function => “alert(‘Element on focus’)”,
:on => :focus %>

observe_field is used to check whether any changes made to the
particular field…
Once u did any change in this particular field that alert was called.

I understand the on: options it to have control over the events like
focus, click, change, blur and such…
It is just that the code in prototype is forcing the default change
irrelevant to :on option that we choose.