Christophe wrote: > Hi there, > > I'm kind of a newbie on RoR and on this group and I was wondering if > someone could help to clean this bit of code: > > <%= link_to_remote (image_tag("hide.png", :size=>"16x16"), > :url=>"/message/#{message.id}/hide", > :method=>"post", > :before=>"Effect.Fade(this.parentNode.parentNode, {duration: > 0.5}); > Effect.BlindUp(this.parentNode.parentNode, {duration: > 0.5})") > %> > <%= link_to_remote (image_tag("top.png", :size=>"16x16"), > :url=>"/message/#{message.id}/top", > :method=>"post", > :before=>"Effect.Fade(this.parentNode.parentNode, {duration: > 0.5}); > Effect.BlindUp(this.parentNode.parentNode, {duration: > 0.5})") > %> > <%= link_to_remote (image_tag("bottom.png", :size=>"16x16"), > :url=>"/message/#{message.id}/bottom", > :method=>"post", > :before=>"Effect.Fade(this.parentNode.parentNode, {duration: > 0.5}); > Effect.BlindUp(this.parentNode.parentNode, {duration: > 0.5})") > %> > > As you can see I have some kind of options that do repeat themselves. > My idea was to find a way to describe them for once and use them > repeatedly. > Any thoughts on how to achieve this,
Well, one thing to do: take the JavaScript out of your ERb files and put it in a separate JavaScript file. This has many advantages, among them the fact that it's easier to reduce repetition. > > Thanks in advance, > > Christophe Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.