如何将目标添加到 Rails 表单助手? [英] How to add target to Rails form helper?

查看:43
本文介绍了如何将目标添加到 Rails 表单助手?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 form_for 助手并希望它提交到 iframe.

I'm using the form_for helper and would like it to submit to an iframe.

<%= form_for(section, :target => 'new_section_frame') do |f| %>
  ...
<% end %>

然后我应该能够调用 $('form').submit() 并将表单提交到 iframe.除了目标不在输出 html 中之外,它会起作用.Rails 表单助手指南 没有这个特定示例.

I should then be able to call $('form').submit() and have the form submit to the iframe. It would work except that the target isn't present in the output html. The Rails guide on form helpers doesn't have this particular example.

推荐答案

与 html 有关的 form_for 助手的选项必须在 html 键中.像这样:

Options for the form_for helper that pertain to html have to be in the html key. Like so:

<%= form_for(section, :html => {:target=>'new_section_frame'}) do |f| %>
  ...
<% end %>

这篇关于如何将目标添加到 Rails 表单助手?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆