【发布时间】:2014-02-10 04:50:54
【问题描述】:
当有人单击显示表单按钮时,我有一个通过 ajax 呈现的表单。表单正确呈现,但未提交。当我按下提交时,什么也没有发生,服务器也没有收到任何东西。这是表格:
<%= form_for @employer_profile, :html => { :class => "clearfix", :id => "the_form"},
remote: true do |f| %>
<%= f.text_field :position, class: "field" %>
<%= f.submit "SAVE", class: "button button-save button-submit" %>
这是生成的html:
<form id="the_form" class="clearfix" method="post" data-remote="true"
action="/employer_profiles/13" accept-charset="UTF-8"
<input id="employer_profile_position" class="field" type="text"
name="employer_profile[position]"></input>
<input class="button button-save button-submit" type="submit" value="SAVE"
name="commit"></input>
为什么表单没有提交?
【问题讨论】:
-
你可以显示生成的动作。
-
没有生成任何东西。我只是点击提交,没有任何反应。
-
显示html代码并寻找
form action="..." -
jquery_ujs.js是否包含在您的 html 代码中?否则remote不起作用。 -
它包含在具有加载ajax表单的按钮的原始页面上。我尝试将它包含在表单页面上,但这并没有使表单工作。
标签: ruby-on-rails ajax jquery ruby-on-rails-4 ajaxform