`
rloc2003
  • 浏览: 57797 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

Ruby ajax实现二级联动菜单

    博客分类:
  • ruby
阅读更多

 

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

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics