无需单击提交按钮即可提交数据 [英] Submitting data without clicking a submit button

查看:90
本文介绍了无需单击提交按钮即可提交数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个包含大量输入行的表。这个想法是每行输入与后端的一个对象相关联。一旦用户不再向其中输入数据,我想要提交一行。

I want to create a table with rows full of inputs. The idea is that each row of inputs ties to one object on the backend. I want a row to be "submitted" once the user is no longer entering data into it.

我主要是后端工程师笨手笨脚的前端,所以我我想知道有什么方法可以获得以下效果:

I'm mostly a backend engineer bumbling with the front end, so I'm wondering what are some approaches to get the following effect:

当用户停止输入时,我想调用后端动作(在MVC意义上)当前行然后在下一行。

I want to call a backend "action" (in the MVC sense) when a user stops inputting in a current row and is then on the next row.

我读过onblur和onfocusout,但似乎都没有做我想要的。 Onblur基于每个输入,即使用户正在通过同一行进行切换,每次输入时都会触发onfocusout。此外,firefox还不支持onfocusout。

I've read about onblur and onfocusout, but neither seem to do what I want. Onblur is on a per-input basis, and onfocusout is triggered each time an input is left even if a user is tabbing through the same row. Further, onfocusout isn't supported by firefox yet.

我的应用程序是grails,但我愿意绕开标准的g:form(grails form)练习和使用某种javascript解决方案。我只是不知道那是什么。

My app is grails, but I'm open to circumventing the standard g:form (grails form) practice and using some sort of javascript solution. I just don't know what that would be.

任何讨论都会有所帮助,因为我试图了解更多有关前端解决方案的信息。如果有任何javascript框架使这更容易,请告诉我们。

Any discussion would be helpful, as I'm trying to learn more about frontend solutions in general. If there are any javascript frameworks that make this easier, let me know about them.

推荐答案

你可以使用javascript提交表单无论你什么时候想要。您可以将提交表单功能附加到任何事件(例如用户理想,模糊您想要的任何其他事件)。然后,如果发生任何事件,您可以调用将提交表单的函数。请参阅下面的示例

you can use javascript to submit a form when ever you want. You can attach the submit form function to any event (like user ideal, blur any other event you want). Then if any of the event happens, you can call that function which will submit the form. see the example below

function idealUser(){//you call that function according to requirement
 setTimeout(function(){
  submitForm();
 },5000);
}
function submitForm(){
document.getElementByID('formId').submit();
}

这篇关于无需单击提交按钮即可提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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