【问题标题】:Onsubmit of a form, open up on a new tab提交表单时,在新选项卡上打开
【发布时间】:2013-12-05 10:48:50
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

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

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

    它将生成以下HTML

    <form target="_blank" ... >
    

    【讨论】:

      猜你喜欢
      • 2014-05-08
      • 1970-01-01
      • 2011-11-10
      • 1970-01-01
      • 2012-11-27
      • 2017-06-23
      • 1970-01-01
      • 2020-10-31
      相关资源
      最近更新 更多