日期:2014-05-16 浏览次数:20613 次
?
view页面代码:
?
<label style="font:bold;">Season<span class="required">*</span></label>
<%= select('season', 'id',
?? ? ?Season.all.collect {|t| [t.name, t.id]}, {:include_blank => true},?
?? ? ? ?{"onchange" => remote_function(
?? ? ? ? ?:with => "'season_id='+value", //传递的参数
?? ? ? ? ?:update => 'series_select', //指定更新的div
?? ? ? ? ?:url => {:controller => :projects, :action => :select_series})})%>?
?
?
<div id="series_select" style="width: 367px;">
</div>
?
controller代码:
?
?def select_series
?? ? ?@series = Series.find(:all, :conditions => ["season_id = ?", params[:season_id]]).collect { |series| [series.name, series.id] }
?? ? ?render :partial => "projects/select_series" //用projects/select_series更新?div id="series_select"
?? ?end
?