rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] How to initially hide a drop-down control and have an image control make it visible

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hi,

I've got the following code in my attempt to provide the subject
functionality, lines 20-29 in view:

<%= image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
<br>
<div name="vendor_droplist">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>

Until I put in the options on image tag and added the div, this code
display a list of vendor nicknames. Now I have several problems:

1. Syntax error in line 20 where an identifier was encountered where a
right-paren was expected (see below)
2. I don't know how to make the vendor_droplist initially hidden

I've Googled for "Rails Ajax toggled item" and got a number of hits
but no apparent answer. I'll keep poking around the Web, but I
appreciate some suggestion(s).

Thanks in advance,
Richard

Showing app/views/expenses/new.html.erb where line #20 raised:

compile error
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:20: syntax error, unexpected tIDENTIFIER, expecting ')'
@output_buffer.concat " "; @output_buffer.concat(( image_tag
"DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } ).to_s);
@output_buffer.concat "\n"

^
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:20: odd number list for Hash
@output_buffer.concat " "; @output_buffer.concat(( image_tag
"DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } ).to_s);
@output_buffer.concat "\n"

^

Extracted source (around line #20):

17: <p>
18: <%= f.label :vendor %><br />
19: <%= f.text_field :vendor %>
20: <%= image_tag "DownArrow.jpg" options =
{ onclick=page["vendor_droplist"].show } %>
21: <br>
22: <div name="vendor_droplist">
23: <%= select_tag "test",

Trace of template inclusion: app/views/expenses/new.html.erb

RAILS_ROOT: K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS
Application Trace | Framework Trace | Full Trace

K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/views/expenses/
new.html.erb:59:in `compile!'
K:/_Projects/Ruby/_Rails_Apps/_EIMS/RTS/app/controllers/
expenses_controller.rb:30:in `new'

--
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@googlegroups.com.
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.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive