[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

In the .rhtml or in the controller

macaco

2/17/2008 4:14:00 PM

[Note: parts of this message were removed to make it a legal post.]

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:

<div id="list">
<div id="dragg0" class="green box"
style="position:absolute;top:190px;left:55px"><div class="handler"
id="handler0">Imagen 0</div><%= link_to_remote
image_tag("/generate/imagen/0"), :url => {:action=> "generate", :id => 0},
:update => "show_div" %></div>
<%= draggable_element :dragg0, :handle => "'handler0'" %>
<div id="dragg1" class="green box"
style="position:absolute;top:190px;left:240px"><div class="handler"
id="handler1">Imagen 1</div><%= link_to_remote
image_tag("/generate/imagen/1"), :url => {:action=> "generate", :id => 1},
:update => "show_div" %></div>
<%= draggable_element :dragg1, :handle => "'handler1'" %>

# the same for N images

</div>
<span id="show_div"></span>


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?

3 Answers

Phlip

2/17/2008 4:36:00 PM

0

macaco wrote:

> Any idea, shall I make it in the controller? it's there a way to do it
> in the .rhtml?

Please take all questions like this to the Ruby-on-Rails Talk group at
Google. You'd get the best answers there, such as "read the fine book,
and then learn to use a 'partial'".

--
Phlip

macaco

2/20/2008 2:57:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

I've come to this

<% 0.upto(7) { |x| %>
<div id="dragg<%= x %>" class="green box"
style="position:absolute;top:<%= 190+((x / 4)*195) %>px;left:<%= 55 + (x *
195) %>px"><div class="handler" id="handler<%= x %>">Imagen <%= x
%>&nbsp;<%= check_box_tag "cruzar"+x.to_s%></div><%= link_to_remote
image_tag("/generate/imagen/"+x.to_s), :url => {:action=> "generate", :id =>
x}, :update => "show_div" %></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 <macacoangel@gmail.com> 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:
>
> <div id="list">
> <div id="dragg0" class="green box"
> style="position:absolute;top:190px;left:55px"><div class="handler"
> id="handler0">Imagen 0</div><%= link_to_remote
> image_tag("/generate/imagen/0"), :url => {:action=> "generate", :id => 0},
> :update => "show_div" %></div>
> <%= draggable_element :dragg0, :handle => "'handler0'" %>
> <div id="dragg1" class="green box"
> style="position:absolute;top:190px;left:240px"><div class="handler"
> id="handler1">Imagen 1</div><%= link_to_remote
> image_tag("/generate/imagen/1"), :url => {:action=> "generate", :id => 1},
> :update => "show_div" %></div>
> <%= draggable_element :dragg1, :handle => "'handler1'" %>
>
> # the same for N images
>
> </div>
> <span id="show_div"></span>
>
>
> 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?
>

The Peeler

6/9/2013 12:14:00 PM

0

On Sat, 08 Jun 2013 17:04:36 -0700, The Rectum, the resident psychopath of
sci and scj, FAKING his time zone again and IMPERSONATING his master, The
Peeler, wrote:

>>
>>so get after ramming his rear dear
>
> don't worry I will keep fantasizing about it

....just like you did nothing else for those SIXTEEN YEARS that you've been
fantasizing about men's arses on Usenet, virtually around the clock, eh,
"The Rectum"? <BG>

--
The Rectum about himself:
"And you just wish someone, anyone, anything would cornhole you!"