# Observe\_field :function show hide doesnt work

**URL:** <https://www.ruby-forum.com/t/observe-field-function-show-hide-doesnt-work/152887>\
**Category:** Rails\
**Created:** [November 9, 2008, 12:53am UTC](https://www.ruby-forum.com/t/observe-field-function-show-hide-doesnt-work/152887 "2008-11-09T00:53:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@ami](https://www.ruby-forum.com/u/ami)\
**Post date:** [November 9, 2008, 12:53am UTC](https://www.ruby-forum.com/t/observe-field-function-show-hide-doesnt-work/152887/1 "2008-11-09T00:53:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ami](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@ami](https://www.ruby-forum.com/u/ami)\
**Post date:** [November 9, 2008, 3:10am UTC](https://www.ruby-forum.com/t/observe-field-function-show-hide-doesnt-work/152887/2 "2008-11-09T03:10:35Z")

</div>

On Nov 8, 11:52 pm, Ami [removed\_email\_address@domain.invalid](mailto: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
