Observe_field :function show hide doesnt work


#1

Repeat: <%= select(:event_template, :freq, {:None => “0”, :Daily =>
“1”, :Weekly => “2”, :Monthly => “3”, :Yearly => “4”, :custom =>
“5” }, {:selected => :None}) %>

<% observe_field(“event_template_freq”, :function =>
‘show_custom_repeat’) %>

i use fire bug and no errors, i’m sure its just my syntax can anyone
help?
Ami


#2

On Nov 8, 11:52 pm, Ami removed_email_address@domain.invalid wrote:

Repeat: <%= select(:event_template, :freq, {:None => “0”, :Daily =>
“1”, :Weekly => “2”, :Monthly => “3”, :Yearly => “4”, :custom =>
“5” }, {:selected => :None}) %>

<% observe_field(“event_template_freq”, :function =>
‘show_custom_repeat’) %>

2 things:

  • That needs to be <%=
    observe_field just returns the appropriate javascript statement so if
    you use <% then that javascript is never inserted into the view.
  • while the statement show_custom_repeat is legal javascript, it is a
    statement with no effect, it just evaluates to the function object (in
    the same way that in ruby the expression “Object” is perfectly legal
    but doesn’t do an awful lot). If you want to call your function you
    need show_custom_repeat() instead of show_custom_repeat

Fred