rails3 ajax替换成js
2013-07-15 02:10 张小萌 阅读(282) 评论(0) 编辑 收藏 举报rails3取消默认的prototype
layouts文件:
<%= javascript_include_tag 'prototype' %>替换为<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
show.html.erb文件:
<%= link_to_remote(..) %>替换为<%= link_to "Refresh seats", "/flights/#{@flight.id}/seats", :remote => true %>
同时建立flight_seats.js.erb文件:
$("#seats").html("<%= escape_javascript( render :partial => '/flights/seat_list', :locals =>{:seats=>@flight.seats}) %>");