当前位置: 代码迷 >> Ajax >> Ruby ajax兑现二级联动菜单
  详细解决方案

Ruby ajax兑现二级联动菜单

热度:950   发布时间:2012-12-21 12:03:49.0
Ruby ajax实现二级联动菜单

?

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

?

  相关解决方案