提交表单,在新选项卡上打开

时间:2013-12-05 10:48:50

标签: javascript ruby-on-rails browser ruby-on-rails-2

选择批次。我在选择学生后渲染部分(显示学生),我应该在新标签中生成pdf。

_batch_students.html.erb

<% form_for :custom_reports, :url=>{:action=>"custom_report_pdf"} do |f| %>
#code
<%= f.submit "► #{t('pdf_report')}", :class=>"submit-button"%>

它目前工作正常,但如何在新标签中获取pdf?需要使用Javascript吗?

目前使用pdf的url看起来像

  

http://localhost:3000/design_custom_reports/custom_report_pdf

chrome重新加载时,我会向resend data提醒我,但在firefox中,它不会提示并导致error

Rails 2,Ubuntu 12.04

1 个答案:

答案 0 :(得分:2)

在html表单上使用属性target="_blank"

<% form_for :custom_reports, :url=>{:action=>"custom_report_pdf"}, :html => {:target => '_blank'} do |f| %>

它将生成以下HTML

<form target="_blank" ... >