我需要使用JS
将参数传递给 rails 控制器:
def page
@select = Firstpage.where( :pid=>params[:par_id])
respond_to do |format|
format.html # page.html.erb
format.json { render json: @select }
end
end
js.coffee
代码:
fetchselect=(val) ->
$.getJSON('firstpages_controller.rb', par_id:val )
$('.homeNav').find('.unactive').click ->
id = $(this).attr('id')
fetchselect(id)