Forum: Ruby on Rails Problem with link_to_function resulting rjs error, please he

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mister Yu (Guest)
on 2007-08-01 16:12
(Received via mailing list)
Hello all,

i am trying to add some ajax effect to the page and use the
link_to_funtion tag to toggle a "comment form" div.

but when i click on the link, firefox gives me error box saying:
RJS error
TypeError: Effect[effect_class] is not a constructor

after i click OK, it says:

here's the code for the div:

<!-- comment_form div-->
<%= link_to_function ("Add a comment", nil, :id =>"add_comment") do |
 page[:comment_form].visual_effect  :toggle_blind
 page[:add_comment].replace_html "Cancel"
<div id="comment_form" style="display: none;">
  <% form_tag :action => 'add_comment', :id =>@place do %>
      <%= render :partial => 'comment_form' %>
      <%= submit_tag "Submit" %>
  <% end %>
<!-- comment_form div-->

what is the problem and how do i fix it?

thanks in advance.
Steven M. (Guest)
on 2007-08-07 15:25
I have exactly the same problem when using a code block to
link_to_function, the only solution I have uncovered is not to use the
code block form.  Unfortunately this is somewhat limited :(

I wish I could be more help...

We can only hope that this problem is fixed!
Jon S. (Guest)
on 2007-08-14 18:41
(Received via mailing list)
I think there may be a bug in Rails... I wanted to use this as well
(it's documented in the Rails API docs as an example at
as a link_to_function example).  I believe it has to do with the use
of the toggle_blind method on the $() prototype function -- maybe that
method is not being added properly?  I tested many different
combinations and did find one that worked:

  page.visual_effect :toggle_blind, 'details'  <== my div id; same as
your "comment_form

Notice that you can't use the element proxy of page[:comment_form] as
it winds up returning the $() form which fails.  Here are the
different variations that I tried:

  page[:details].visual_effect :toggle_blind
  page[:details].visual_effect('element', :toggle_blind)
  page[:details].visual_effect('details', :toggle_blind)
  page[:details].visual_effect :blind

All of the above give that "not a constructor" error.

BUT... Note that a simple "toggle" (view/hide) DOES work:


Jon S. (Guest)
on 2007-08-14 18:51
(Received via mailing list)
Correction: some of the error statements give a "$
('details').toggleBlind is not a function" error...jon
This topic is locked and can not be replied to.