Hi All,
Inside my app\views\expenses\new.html.erb file, I had the code:
<% form_for(@expense) do |f| %>
[snip]
<p>
<%= f.label :vendor %><br />
<%= f.text_field :vendor %>
<br />
<div id="vendor_droplist>
<%= select_tag "test",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
</div>
</p>
It brought up a list of vendor-names immediately under my Vendors
textbox, which worked great as far as I was concerned. Then I tried
to turn it into a real drop-down:
1. I added style="display:none" to the div so that the drop-down was
hidden when the page opened
2. I added <%= button_to_function("ShowList",
%<page.toggle :vendor_droplist> ) %> following the text_field
Hiding the drop-down worked, but the button failed to restore it.
Validating the resulting HTML revealed the a div is not permitted in
the scope of a form.
To solve this I removed the <div> opening and closing tags and:
1. added the id to the select_tag:
<%= select_tag "test" :id="vendor_droplist",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
2 added it with a comma
<%= select_tag "test", :id="vendor_droplist",
options_for_select(@current_vendors.collect { |v|
v.nickname }),
{:multiple => true} %>
Neither these nor any other change I tried worked. So what's the
Rail's way of solving this problem?
I'm running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6, MySQL
5.0.37-community-nt, Mongrel.
Thanks in Advance,
Richard
--
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