本文介绍了onsubmit:返回false;如果远程,则忽略:Rails 4中为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Rails 4中的格式如下:
I have the following form in Rails 4:
<%= form_tag("editor/work", remote: true, method: "post", name: "myform", onsubmit: "validateForm()", target:"_blank", id: "editor_form") do %>
我的validateForm函数如下:
My validateForm function looks like this:
function validateForm() {
return false;
}
即使被调用,也会执行AJAX提交.我该如何避免呢?因此,如果功能validateForm返回false,那么我避免提交AJAX吗?
Even though it gets called, the AJAX submission is performed. How can I avoid that? So, if the function validateForm returns false, I avoid the AJAX submission?
推荐答案
尝试键入而不是:
onsubmit: "validateForm()"
此:
:onclick => "return validateForm();"
这篇关于onsubmit:返回false;如果远程,则忽略:Rails 4中为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!