提交表单后,打开一个新的选项卡

Onsubmit of a form, open up on a new tab

本文关键字:一个 选项 表单 提交      更新时间:2024-03-25

关于批次的选择。我渲染了一个部分(显示学生),在选择学生后,我应该在一个新的选项卡中生成一个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

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

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

它将生成以下HTML

<form target="_blank" ... >