【发布时间】:2011-07-05 11:11:20
【问题描述】:
我正在使用带有 link_to 远程选项的 rails 3 工作。
这是我的代码结构。
查看/打孔/report.html.erb:
<%= link_to 'Punch report', punchreport_punch_index_path, :remote => true%>
<div id="punchform"> </div>
查看/punch/punchreport.js.erb:
$("#punchform").html("<%= escape_javascript(render(:partial => "reportform"))%>");
并在里面创建了一个表单
查看/punch/_reportform.html.erb
和控制器:
控制器/punch_controller.rb
def report
end
def punchreport
respond_to do |format|
format.html { render report_punch_index_path }
format.js
end
end
注意:punchreport_punch_index_path:/punch/punchreport
report_punch_index_path : /punch/report
我没有让 ajax 请求正常工作。相反,它会重定向页面。
任何帮助 在此先感谢
【问题讨论】:
标签: ajax ruby-on-rails-3