下拉框ajax特效
在layout主模板或者view中加入<%= javascript_include_tag 'prototype' %>
在需要放置下拉框的地方设置
<%= collection_select(:member, :company_province, @province, :provinceid, :province,options ={:prompt => '一级分类'},
html_options = {:onChange => remote_function(:update => "person_area_places_box",
:url => { :action => :select_change}, :with => "'provinceid='+value" )} ) %>
<span id="person_area_places_box">
</span>
再controller中定义
def select_change
@city=City.find(:all, :conditions => ["fatherid = ?",params[:provinceid]])
render:partial => "city"
end
再创建一个_city.rhtml
在layout主模板或者view中加入<%= javascript_include_tag 'prototype' %>
在需要放置下拉框的地方设置
<%= collection_select(:member, :company_province, @province, :provinceid, :province,options ={:prompt => '一级分类'},
html_options = {:onChange => remote_function(:update => "person_area_places_box",
:url => { :action => :select_change}, :with => "'provinceid='+value" )} ) %>
<span id="person_area_places_box">
</span>
再controller中定义
def select_change
@city=City.find(:all, :conditions => ["fatherid = ?",params[:provinceid]])
render:partial => "city"
end
再创建一个_city.rhtml