I have a list in my page and I want to show there additional information like: my link + show me more my 2 link + show me more etc.. I have a element for hidden info: <div id="link_long_<%= link.id %>" style="display:none"> <%= link.long %> </div> How can I pass a link id with something like this: <%= link_to_function "+", "link_long_id".toggle(), :style => ''text-decoration:none'' %></td> This does not work. Thank you! -- 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 -~----------~----~----~----~------~----~------~--~---
On Apr 18, 5:10 pm, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a list in my page and I want to show there additional information > like: > > my link > + show me more > my 2 link > + show me more > etc.. > > I have a element for hidden info: > <div id="link_long_<%= link.id %>" style="display:none"> > <%= link.long %> > </div> > > How can I pass a link id with something like this: > > <%= link_to_function "+", "link_long_id".toggle(), :style => > ''text-decoration:none'' %></td>well assuming the link had id 23, the javascript you''d want to generate would be $(''link_long_23'').toggle() - just build up that string, using the usual string interpolation stuff for example Fred> This does not work. > > Thank you! > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Apr 18, 5:10�pm, Marika Ahonen <rails-mailing-l...@andreas-s.net> > wrote: >> <div id="link_long_<%= link.id %>" �style="display:none"> >> <%= link.long %> >> </div> >> >> How can I pass a link id with something like this: >> >> � � � <%= link_to_function "+", "link_long_id".toggle(), :style => >> ''text-decoration:none'' %></td> > > well assuming the link had id 23, the javascript you''d want to > generate would be $(''link_long_23'').toggle() - just build up that > string, using the usual string interpolation stuff for example > > FredYes, but how can I pass link_long_id instead of giving the link_long_23? I can''t get that working :( -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 18, 8:03 pm, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Apr 18, 5:10 pm, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> <div id="link_long_<%= link.id %>" style="display:none"> > >> <%= link.long %> > >> </div> > > >> How can I pass a link id with something like this: > > >> <%= link_to_function "+", "link_long_id".toggle(), :style => > >> ''text-decoration:none'' %></td> > > > well assuming the link had id 23, the javascript you''d want to > > generate would be $(''link_long_23'').toggle() - just build up that > > string, using the usual string interpolation stuff for example > > > Fred > > Yes, but how can I pass link_long_id instead of giving the link_long_23? > I can''t get that working :(Like I said, string interpolation: greeting = "world" puts "hello #{greeting}" Fred> -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Apr 18, 8:03�pm, Marika Ahonen <rails-mailing-l...@andreas-s.net> > wrote: >> >> ''text-decoration:none'' %></td> >> >> > well assuming the link had id 23, the javascript you''d want to >> > generate would be $(''link_long_23'').toggle() - just build up that >> > string, using the usual string interpolation stuff for example >> >> > Fred >> >> Yes, but how can I pass link_long_id instead of giving the link_long_23? >> I can''t get that working :( > > Like I said, string interpolation: > > greeting = "world" > puts "hello #{greeting}" > > FredThank you Fred for your answer, but unfortunately that doesn''t work. I get an error: ''undefined method `toggle'' for "link_long_23":String'' So it gets the id correctly, problem is the toggle? I''m quite new with all this, so I''m sorry if I ask stupid questions ;) -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 19, 10:14 am, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Apr 18, 8:03 pm, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> >> ''text-decoration:none'' %></td> > > >> > well assuming the link had id 23, the javascript you''d want to > >> > generate would be $(''link_long_23'').toggle() - just build up that > >> > string, using the usual string interpolation stuff for example > > >> > Fred > > >> Yes, but how can I pass link_long_id instead of giving the link_long_23? > >> I can''t get that working :( > > > Like I said, string interpolation: > > > greeting = "world" > > puts "hello #{greeting}" > > > Fred > > Thank you Fred for your answer, but unfortunately that doesn''t work. I > get an error: > ''undefined method `toggle'' for "link_long_23":String'' > So it gets the id correctly, problem is the toggle? I''m quite new with > all this, so I''m sorry if I ask stupid questions ;)that sounds like you''re still doing something like link_to_function ,''blah'', "$(''something'')".toggle That''s not what you want to do. you want to create the string "$ (''something'').toggle" and pass that as the second argument to link_to_function (that second argument should be a fragment of javascript). Fred> -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Apr 19, 10:14�am, Marika Ahonen <rails-mailing-l...@andreas-s.net> > wrote: >> >> Thank you Fred for your answer, but unfortunately that doesn''t work. I >> get an error: >> ''undefined method `toggle'' for "link_long_23":String'' >> So it gets the id correctly, problem is the toggle? I''m quite new with >> all this, so I''m sorry if I ask stupid questions ;) > > that sounds like you''re still doing something like > > link_to_function ,''blah'', "$(''something'')".toggle > > That''s not what you want to do. you want to create the string "$ > (''something'').toggle" and pass that as the second argument to > link_to_function (that second argument should be a fragment of > javascript). > > FredThanks again :) I don''t really know how I am supposed to do that :( I''m doing: <% linkki = (''link_long_''+link.id.to_s).toggle %> <%= link_to_function "+", linkki, :style => ''text-decoration:none'' %> -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 19, 11:07 am, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > Thanks again :) I don''t really know how I am supposed to do that :( I''m > doing: > <% linkki = (''link_long_''+link.id.to_s).toggle %>If you do that you''re trying to call a ruby function called toggle. What you want to do is generate a javascript fragment that calls a toggle function, so .toggle() needs to be inside the string that you generate, not outside as it is here. Fred> <%= link_to_function "+", linkki, :style => ''text-decoration:none'' %> > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
<%= link_to_function "+", "$(''link_long_id'').toggle()", :style => ''text-decoration:none'' %></td> On Sun, Apr 19, 2009 at 12:10 AM, Marika Ahonen < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I have a list in my page and I want to show there additional information > like: > > my link > + show me more > my 2 link > + show me more > etc.. > > I have a element for hidden info: > <div id="link_long_<%= link.id %>" style="display:none"> > <%= link.long %> > </div> > > How can I pass a link id with something like this: > > <%= link_to_function "+", "link_long_id".toggle(), :style => > ''text-decoration:none'' %></td> > This does not work. > > Thank you! > -- > Posted via http://www.ruby-forum.com/. > > > >-- Yes! I''m HeChian :) http://hechian36.pixnet.net/blog --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try link_to_function "+", "Effect.toggle (''$(''something'')'', ''slide'');" this should, if it works, throw in a nice sliding effect for u too.. On Apr 19, 4:05 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Apr 19, 11:07 am, Marika Ahonen <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > Frederick Cheung wrote: > > > Thanks again :) I don''t really know how I am supposed to do that :( I''m > > doing: > > <% linkki = (''link_long_''+link.id.to_s).toggle %> > > If you do that you''re trying to call a ruby function called toggle. > What you want to do is generate a javascript fragment that calls a > toggle function, so .toggle() needs to be inside the string that you > generate, not outside as it is here. > > Fred > > > <%= link_to_function "+", linkki, :style => ''text-decoration:none'' %> > > -- > > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---