Hi,
I am trying to set a default value for a text field used for a search, which uses the observe method. Here's what I got which works.
<% form_tag('javascript:void(0)') do %>
<%= text_field_tag 'phrase', nil, {:onfocus => "$('results').show();", :onblur => "$('results').hide();"} %>
<%= observe_field :phrase,
:frequency => 0.5,
:update => 'results',
:url => {:controller => :profiles, :action => 'search', :only_path => false },
:with => "'phrase=' + encodeURIComponent(value)" %>
<% end %>
This works fine, but obviously the value is nil.
Now if I add in the value like so:
<% form_tag('javascript:void(0)') do %>
<%= text_field_tag 'phrase', :value => 'test', {:onfocus => "$('results').show();", :onblur => "$('results').hide();"} %>
<%= observe_field :phrase,
:frequency => 0.5,
:update => 'results',
:url => {:controller => :profiles, :action => 'search', :only_path => false },
:with => "'phrase=' + encodeURIComponent(value)" %>
<% end %>
An exception is thrown.
Any idea on how I can get a default value for this text field?
Thank you.