rubyonrailsin

A Ruby and Rails talk

Saturday, March 20, 2010


[Rails] Re: 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

OK, I got rid of all the syntax errors.
The vendor_drop list is now hidden on startup of the view
I switched from an image to a button
However, the drop list does not get displayed when the ShowList button
is clicked
Code is below. Ideas are most welcome


<%= button_to_function("ShowList",
%<page["vendor_droplist"].show> ) %>
<br>
<div id="vendor_droplist", style="display:none">
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>


On Mar 21, 12:37 am, RichardOnRails
<RichardDummyMailbox58...@USComputerGurus.com> wrote:
> I think I improved two things in the version of lines 20-26 below:
> 1. I gave the div an id rather than a name
> 2. I gave the div a style of "display:none" so that it's hidden at
> every startup of the view
>
>     <%# = image_tag "DownArrow.jpg" options =
> { onclick=page["vendor_droplist"].show } %>
>     <br>
>     <div id="vendor_droplist", style="display:none">
>         <%= select_tag "test",
>               options_for_select(@current_vendors.collect { |v|
> v.nickname }),
>               {:multiple => true} %>
>     </div>
>
> On Mar 21, 12:07 am, RichardOnRails
>
> <RichardDummyMailbox58...@USComputerGurus.com> wrote:
> > 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