我有几个选择轨使用的ActionView助手
<p>
<%= f.label :reason %><br />
<%= f.select :reason, Confirmation.reasons.collect {|p| [ p[:name], p[:id] ] }, { :include_blank => true } %>
</p>
最后被ID =“5”和名称=“其他”
当且仅当他们选择其他的我想有一个选择菜单的observe_field一个div id =“other”的隐藏text_area被显示为允许用户键入...
我该怎么做到这一点?
<%= link_to_function "Show me other" do |page|
page[:other].toggle
end %>
我可以切换它,但我想显示它在选择框中的“其他”?这是一个为observe_field工作吗?
*道德*含义?! ;-) – 2009-09-16 12:17:55
但observe_field使用ajax?客户方只有等同的东西? – holden 2009-09-16 13:03:22
<%= f.select:reason,Confirmation.reasons.collect {| p | [p [:name],p [:id]]},{:include_blank => true},{:onchange =>“$('otherform')。show();” }%>适用于整个表格 – holden 2009-09-16 13:30:30