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: $("comment_form").visualEffect("toggle_blind"); $("add_comment").update("Cancel"); here's the code for the div: <!-- comment_form div--> <%= link_to_function ("Add a comment", nil, :id =>"add_comment") do | page| page[:comment_form].visual_effect :toggle_blind page[:add_comment].replace_html "Cancel" end %> <div id="comment_form" style="display: none;"> <% form_tag :action => 'add_comment', :id =>@place do %> <%= render :partial => 'comment_form' %> <%= submit_tag "Submit" %> <% end %> </div> <!-- comment_form div--> what is the problem and how do i fix it? thanks in advance.
on 2007-08-01 16:12
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!
on 2007-08-14 18:41
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 http://api.rubyonrails.com/classes/ActionView/Help... 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 page[:details].toggle_blind All of the above give that "not a constructor" error. BUT... Note that a simple "toggle" (view/hide) DOES work: page[:details].toggle HTH...jon
on 2007-08-14 18:51
Correction: some of the error statements give a "$ ('details').toggleBlind is not a function" error...jon