Hi! I''am using Effect.toggle to show/hide a div field. Is there a simple way to also toggle the icon i am using. (+ if hidden and - if visible) <%= link_to_function '''', "Effect.toggle(''summary_dropdown'')", :class => ''icon-expand'' %> Thanks. -- 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 3 Nov 2008, at 14:52, Mikael Björkegren wrote:> > Hi! > > I''am using Effect.toggle to show/hide a div field. Is there a simple > way > to also toggle the icon i am using. (+ if hidden and - if visible) >I typically do that by also toggling some css class (eg $ (''something'').toggleClassName(''expanded''). in this case you can probably do this.toggleClassName(''some-class'') ) Fred> <%= link_to_function '''', > "Effect.toggle(''summary_dropdown'')", > :class => ''icon-expand'' %> > > Thanks. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the quick reply. But where am i going to put this?> I typically do that by also toggling some css class (eg $ > (''something'').toggleClassName(''expanded''). in this case you can > probably do this.toggleClassName(''some-class'') ) > > Fred<%= link_to_function '''', "Effect.toggle(''summary_dropdown'')", :id => ''toggle'', :class => ''icon-expand'' %> I guess it should be someting like (''toggle'').toggleClassName(''icon-fade'') but where will i put this in my link_to_function ? -- 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 -~----------~----~----~----~------~----~------~--~---
I can only get one off them to work at a time. Do anyone know how to combine the two functions. So the div will fade/appear and the icon will change from + to -. -- 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 4 Nov 2008, at 09:02, Mikael Björkegren wrote:> > Thanks for the quick reply. But where am i going to put this? > >> I typically do that by also toggling some css class (eg $ >> (''something'').toggleClassName(''expanded''). in this case you can >> probably do this.toggleClassName(''some-class'') ) >> >> Fred > > <%= link_to_function '''', > "Effect.toggle(''summary_dropdown'')", > :id => ''toggle'', > :class => ''icon-expand'' %> > > I guess it should be someting like > (''toggle'').toggleClassName(''icon-fade'') > > but where will i put this in my link_to_function ?the second argument to link_to_function is an arbitrary javascript fragment. You can put as much in there as you want. Fred> > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> > the second argument to link_to_function is an arbitrary javascript > fragment. You can put as much in there as you want. > > FredTo give just a little more detail to what Fred said, you can do something like "Effect.toggle(''this-thing''); Effect.toggle(''that-thing'');" Just remember that needs to be proper JavaScript since it''s going to be eval''d. Peace. -- 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 -~----------~----~----~----~------~----~------~--~---
Got it working thanks for the reply. -- 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 -~----------~----~----~----~------~----~------~--~---