Hi all,
I am really new to Ruby so I haven''t figured out all of the iterative
functions yet, but here is my situation and I appreciate your input.
I am trying to utilize a custom method inside my application helper that
will tie into tabbed forms. The concept is to change various DOM
elements on page load so that their visibility is hidden when the page
is loaded (e.g. new.rhtml) and then when the appropriate tab is click a
link_to_function call will change their visibility. I am attempting to
set the hash values inside the partial then return them using "yield"
inside the <body> tag.
So, here is what I have so far:
application.rhtml (default layout)
<body onload=<%= yield :onload_content %>>
application_helper.rb
def onload_content( options = {} )
content_for :onload_content do
if options.blank?
nil
else
options.each_pair do |key, value|
"$(''#{key}'').#{value}();"
end
end
I am taking advantage of the Prototype library such that i can call:
$(element).hide() or $(element).show()
so...
I make a call to the onload_content method from inside the partial
containing the DOM elements I wish to hide onload:
_form.rhtml
<% onload_content :contacts => :hide, :notes => :hide, :demographics
=>
:show %>
...remainder of form ...
however, when I attempt to set the options I receive TypeError exception
returning : "(eval):1:in `+'': can''t convert Hash into
String"
I know this is a syntax mistake I am making, but I''ve been looking over
my copy of Pickaxe and browsing the Net without much help. If you
guys/gals could point me in the right direction, I would really
appreciate it.
- Mike
P.S. if any of you have come across a better solution I would love the
ideas!!
--
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-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
-~----------~----~----~----~------~----~------~--~---