コレクションの選択 (ドロップダウン) ボックスに基づいて表示したい単一のモデルに大量のデータがあります。断面データはこんな感じ・・・
class CreateSections < ActiveRecord::Migration
def change
create_table :sections do |t|
t.string :supervisor
t.string :catagory
t.string :title
t.string :description
t.string :days
t.string :start_date
t.string :end_date
t.string :start_time
t.string :end_time
t.string :course_id
t.string :room
t.string :building
t.string :location
t.string :tuition
t.string :lab_fee
t.string :insurance_fee
t.string :technology_fee
t.timestamps
end
end
end
私のコレクションの選択は次のようになります...
collection_select(:section, :section_id, @sections, :id, :title)
そのため、ユーザーはドロップダウンからタイトルを選択し、説明を表示したいと思います。理想的には、jquery でこれを行いたいと考えています。
編集
htmlがどのように見えるかについての詳細は次のとおりです...
<select id="section_section_id" name="section[section_id]"><option value="1">Long Title</option>
<option value="2"> Alternative Investments for Small Business NEW</option>
<option value="3">Bookkeeping Basics for the Natural Products Industry NEW </option>
...
app/assets/javascripts/sections.js に...
$(function(){
$("#section_section_id").change(function(){
alert('wintas');
})
})
選択したオプションに基づいて、そのオプションに関連付けられた値を表示したいと思います。