From: macaco Date: 2008-02-20T11:57:03+09:00 Subject: Re: In the .rhtml or in the controller ------=_Part_15375_17349042.1203476231331 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I've come to this <% 0.upto(7) { |x| %>
Imagen <%= x %> <%= check_box_tag "cruzar"+x.to_s%>
<%= link_to_remote image_tag("/generate/imagen/"+x.to_s), :url => {:action=> "generate", :id => x}, :update => "show_div" %>
<%= draggable_element "dragg"+x.to_s, :handle => "'handler"+x.to_s+"'" %> <% } %> Someone out there might be needing this. :) Just be careful with the use of <%= x %> and simply 'x' (without the quotes) or x.to_s On 2/17/08, macaco wrote: > > Hi list > I'v been wondering how to make an 'each' or a loop or something so I don't > have to write this code N times: > >
>
style="position:absolute;top:190px;left:55px">
id="handler0">Imagen 0
<%= link_to_remote > image_tag("/generate/imagen/0"), :url => {:action=> "generate", :id => 0}, > :update => "show_div" %>
> <%= draggable_element :dragg0, :handle => "'handler0'" %> >
style="position:absolute;top:190px;left:240px">
id="handler1">Imagen 1
<%= link_to_remote > image_tag("/generate/imagen/1"), :url => {:action=> "generate", :id => 1}, > :update => "show_div" %>
> <%= draggable_element :dragg1, :handle => "'handler1'" %> > > # the same for N images > >
> > > > As you can see, it's just the same code but the Id of the image and a > position. But If I put this code in the controller, I can't create those > <%= %> tags, they won't be recognized. Or at least it didn't for me. > > Any idea, shall I make it in the controller? it's there a way to do it in > the .rhtml? > ------=_Part_15375_17349042.1203476231331--