hi all,
I''m trying to toggle the caption of a link between show archive and
hide archive? Everytime a user clicks the link the caption should
change.
I tried but this simply doesn''t work.
Someone can help me out?
Thanks
Stijn
<div id="show_archive">
<%= link_to_function "Show archive" do |page|
if page[''show_archive''].value == "Show
archive"
page[''show_archive''].replace_html("Hide
archive")
else
page[''show_archive''].replace_html("Show
archive")
end
end %>
</div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Tarscher.
First off you should download and install Firebug for firefox to help
you debug any javascript errors you may be having. http://getfirebug.com/
The problem you are having is because you are calling a non-existent
method, value(), on the div element. There is also no RJS method
called value:
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html
You should probably just use plain ol javascript for this one so you
can check the current innerHTML of the div.
ie. if ($(''show_archive'').innerHTML == ''Show
archive'') { ... }
Or you could set some arbitrary attribute on the div and check it
ie...
<div id=''show_archive'' expanded=''true''
%></div>
if
($(''show_archive'').readAttribute(''expanded'')
== ''true'') { ... }
Cheers.
--
Robert Zotter
Zapient, LLC
Ruby on Rails Development and Consulting
http://www.zapient.com
http://www.fromjavatoruby.com
On Nov 13, 8:56 am, Tarscher
<tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> hi all,
>
> I''m trying to toggle the caption of a link between show archive
and
> hide archive? Everytime a user clicks the link the caption should
> change.
>
> I tried but this simply doesn''t work.
>
> Someone can help me out?
>
> Thanks
> Stijn
>
> <div id="show_archive">
> <%= link_to_function "Show archive" do |page|
> if page[''show_archive''].value == "Show
archive"
> page[''show_archive''].replace_html("Hide
archive")
> else
> page[''show_archive''].replace_html("Show
archive")
> end
> end %>
> </div>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
You might take a look at this: http://wiki.rubyonrails.org/rails/pages/HowtoUseElement Rick On Nov 13, 6:56 am, Tarscher <tarsc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi all, > > I''m trying to toggle the caption of a link between show archive and > hide archive? Everytime a user clicks the link the caption should > change. > > I tried but this simply doesn''t work. > > Someone can help me out? > > Thanks > Stijn > > <div id="show_archive"> > <%= link_to_function "Show archive" do |page| > if page[''show_archive''].value == "Show archive" > page[''show_archive''].replace_html("Hide archive") > else > page[''show_archive''].replace_html("Show archive") > end > end %> > </div>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---