我有幾個選擇軌使用的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