[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Need help with if statement in helper class and view.

jimjohnlists@yahoo.com

3/9/2007 5:02:00 AM

I don't know if this is a ruby only question or a rails question. I
have a helper class that updates the view based on the info from the
div tag. This information is passed using the link_to_function. But it
doesn't work. I don't know how to access the page elements. Also, is
the if statement syntax correct for ruby? Thank you in advance for any
help.

Is it if x1 == 'x1' or is it if x1 = 'x1'?

module VideosHelper
def hide_and_reset(div, div2)
update_page do |page|
if page[div].title == 'show'
page[div].hide
page[div].title = 'hide'
else
page[div].show
page[div].title = 'show'
end
end
end


<tr><td align="center">
<%= link_to_function image_tag("graphics/
select04.gif", :alt=>'Programming', :size=>'100x20', :border=>0),
hide_and_reset(:select02_div, :select01_div) %>
<div id="select02_div" title="1">
<h4>test</h4>
</div>

1 Answer

Anthony Eden

3/9/2007 5:59:00 AM

0

The equality operator in Ruby is ==

As for the question regarding accessing and updating page elements
that is better suited for the Rails talk list. However, the key to how
to work with elements might be at
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMe...

V/r
Anthony Eden

On 3/9/07, jimjohnlists@yahoo.com <jimjohnlists@yahoo.com> wrote:
> I don't know if this is a ruby only question or a rails question. I
> have a helper class that updates the view based on the info from the
> div tag. This information is passed using the link_to_function. But it
> doesn't work. I don't know how to access the page elements. Also, is
> the if statement syntax correct for ruby? Thank you in advance for any
> help.
>
> Is it if x1 == 'x1' or is it if x1 = 'x1'?
>
> module VideosHelper
> def hide_and_reset(div, div2)
> update_page do |page|
> if page[div].title == 'show'
> page[div].hide
> page[div].title = 'hide'
> else
> page[div].show
> page[div].title = 'show'
> end
> end
> end
>
>
> <tr><td align="center">
> <%= link_to_function image_tag("graphics/
> select04.gif", :alt=>'Programming', :size=>'100x20', :border=>0),
> hide_and_reset(:select02_div, :select01_div) %>
> <div id="select02_div" title="1">
> <h4>test</h4>
> </div>
>
>
>


--
Cell: 808 782-5046
Current Location: Melbourne, FL