# RJS and :visual\_effect

**URL:** <https://www.ruby-forum.com/t/rjs-and-visual-effect/149119>\
**Category:** Rails\
**Created:** [September 20, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119 "2008-09-20T22:41:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [September 20, 2008, 10:41pm UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119/1 "2008-09-20T22:41:05Z")

</div>

Hi everyone,

I’m working with rails 2.1.1 and i’m in trouble with the scriptaculous  
helper.

I have something like :

\<%= link\_to\_function “Details” do |page|  
page[‘toto’].visual\_effect(:toggle\_blind)  
end %\>

 Bouh 

Which generates :

\<a onclick=“try { $(“toto”).visualEffect(“toggle\_blind”); } catch (e) {  
alert(‘RJS error:\n\n’ + e.toString());  
alert(’$(“toto”).visualEffect(“toggle\_blind”);’); throw e }; return  
false;” href="#"\>Details

 Bouh 

When i click it under firefox, I get the error :

RJS error:

TypeError: Effect[klass] is not a constructor

I get approximatively the same error on safari.

Does anyone see what’s the problem ?

Thanks

Olivier

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [September 20, 2008, 10:56pm UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119/2 "2008-09-20T22:56:52Z")

</div>

Finally, i made it work but by coding :

My old code :

link\_to\_function(“Show me more”, nil, :id =\> “more\_link”) do |page|  
page[:details].visual\_effect :toggle\_blind  
page[:more\_link].replace\_html “Show me less”  
end

doesnt work.

I think the page  
[http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M001687](http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M001687)  
should be modified because it gives a non working example !

cheers

–  
Olivier

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [September 21, 2008, 12:09am UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119/3 "2008-09-21T00:09:53Z")

</div>

Hi, did you include the following line of code in your head tag:  
\<%= javascript\_include\_tag :defaults %\>

-Conrad

On Sat, Sep 20, 2008 at 1:56 PM, Olivier S. \<

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [October 1, 2008, 1:43am UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119/4 "2008-10-01T01:43:44Z")

</div>

I’m trying to accomplish the same thing with no luck. So did you just  
code the javascript yourself instead of using the helpers?

I second that the documentation seems to be inaccurate…

On Sep 20, 4:56 pm, Olivier S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![rvork](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f6c823/32.png) [@rvork](https://www.ruby-forum.com/u/rvork)\
**Post date:** [October 1, 2008, 7:30am UTC](https://www.ruby-forum.com/t/rjs-and-visual-effect/149119/5 "2008-10-01T07:30:09Z")

</div>

This syntax worked for me:

\<%= link\_to\_function “Details” do |page|  
page.visual\_effect(:toggle\_blind, ‘toto’)  
end %\>

 Bouh 

- Greg
