Mister Yu
2007-Aug-01 12:11 UTC
Problem with link_to_function resulting rjs error, please help.
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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Steven Mead
2007-Aug-07 11:25 UTC
Re: Problem with link_to_function resulting rjs error, pleas
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! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
JSeidel
2007-Aug-14 14:39 UTC
Re: Problem with link_to_function resulting rjs error, please help.
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/Helpers/JavaScriptHelper.html
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 Aug 1, 5:11 am, Mister Yu
<eryan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
JSeidel
2007-Aug-14 14:51 UTC
Re: Problem with link_to_function resulting rjs error, please help.
Correction: some of the error statements give a "$
(''details'').toggleBlind is not a function" error...jon
On Aug 14, 7:39 am, JSeidel
<jsei...-SqBBwp4wwK4AvxtiuMwx3w@public.gmane.org>
wrote:> 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
athttp://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelpe...
> as a link_to_function example). I believe it has to do with the use
> of thetoggle_blindmethod 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 Aug 1, 5:11 am, Mister Yu
<eryan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > 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.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---