我正在使用select2工具以activeadmin形式显示下拉列表。我想根据上一个下拉列表中的上一个选定选项填充下一个下拉列表。
Selec2
的用法如下:
customer_location.input :province, as: :select2, collection: Region.all.map {|prov| prov.province}.uniq , :input_html => { :class => 'select2-input', :width => 'auto', "data-placeholder" => 'Select Province' }
# customer_location.input :city, as: :select2, collection: Region.where(province: selected.province).all.map {|c| c.city}.uniq , :input_html => { :class => 'select2-input', :width => 'auto', "data-placeholder" => 'Select City' }
customer_location.input :area, as: :select2, collection: Region.all.map {|u| [u.area.to_s]}, :input_html => { :class => 'select2-input', :width => 'auto', "data-placeholder" => 'Select Area' }
customer_location.input :address
customer_location.input :address_type, as: :select, collection: ['Comercial', 'Domestic'], :include_blank => false
我想根据所选省份填充“城市”的下拉菜单。 selected
不适用于此目的。