I''m trying to code this anchor tag in Rails. It''s just a link to use scriptaculous to "blind" open a div that I''ve got hidden by default. <a href="#" onClick="Effect.toggle(''add_comment'',''blind''); return false">Add comment</a> Also, how would Rails degrade this link if javascript was disabled? In other words, how do I get it to display by default if javascript was disabled? Or would I be responsible for that, not Rails? Thanks for any help. -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-07 15:18 UTC
Re: How do I code this anchor tag as a link_to in Rails?
On 7 Apr 2008, at 16:12, Jl Smith wrote:> > I''m trying to code this anchor tag in Rails. It''s just a link to use > scriptaculous to "blind" open a div that I''ve got hidden by default. > > <a href="#" onClick="Effect.toggle(''add_comment'',''blind''); return > false">Add comment</a>link_to_function ''Add Comment'', ''your javascript here''> > > Also, how would Rails degrade this link if javascript was disabled? > In > other words, how do I get it to display by default if javascript was > disabled? Or would I be responsible for that, not Rails?You would have to do that. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Fred. That worked great. But as far as me allowing non-javascript users to see the form by default, I was thinking I could just use javascript to set the "display: none" styling. I tried that by doing this: <%= javascript_tag "window.document.getElementById(add_comment).style.display=none;", :defer => ''defer'' -%> but I get a javascript error "add_comment is not defined". I know it''s defined but am I implementing the javascript incorrectly? What''s the "rails way" to do this? Put my javascript somewhere else, instead of at the bottom of this particular view I''m in? Thanks again. -- 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 -~----------~----~----~----~------~----~------~--~---
And btw, here''s the html for "add_comment": <div id="add_comment"><div> <h3>Add Comment</h3> <%= render :partial => @comment = Comment.new, :locals => { :button_name => ''Add comment'' } -%> </div></div> -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-07 16:02 UTC
Re: How do I code this anchor tag as a link_to in Rails?
On 7 Apr 2008, at 16:45, Jl Smith wrote:> > Thanks Fred. That worked great. > > But as far as me allowing non-javascript users to see the form by > default, I was thinking I could just use javascript to set the > "display: > none" styling. I tried that by doing this: > > <%= javascript_tag > "window.document.getElementById(add_comment).style.display=none;", > :defer => ''defer'' -%> >You needed to quote it (getElementById(''add_comment'')). You can write this more concisely if you''re using prototype: $(''add_comment'').hide() Fred> but I get a javascript error "add_comment is not defined". I know > it''s > defined but am I implementing the javascript incorrectly? What''s the > "rails way" to do this? Put my javascript somewhere else, instead > of at > the bottom of this particular view I''m in? > > Thanks again. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks again Fred...you''re the man. Prototype really cleaned that up. And I guess I didn''t need to use the "defer" option...seems to work without it? -- 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 -~----------~----~----~----~------~----~------~--~---