Grails远程表单,使用javascript进行多次提交 [英] grails remote form, multiple submits, with javascript
问题描述
我遇到的情况是我有一个带有多个提交按钮的表单,并且我想更新一个远程框架.我尝试使用带有2个g:actionsubmit
按钮(支持javascript)的g:formremote
,但是多个提交按钮有一个小故障(在这里描述: http://www.grails.org/Ajax 在带有formRemote的多个按钮"下).
I have a situation where I have a form with multiple submit buttons and I want to update a remote frame. I've tried using a g:formremote
with 2 g:actionsubmit
buttons (which support javascript) but the multiple submit buttons have a glitch (described here: http://www.grails.org/Ajax under "Multiple buttons with formRemote").
我采用了2个g:submittoremote
按钮进行了变通,其工作方式与我预期的相同,但是不接受onClick
之类的javascript参数(有问题的按钮为接受/拒绝,我想放置一个AYS在废品上,这样就不会意外使用.)
I took the workaround, using 2 g:submittoremote
buttons, which work the way I expect, but doesn't accept the javascript parameters like onClick
(the buttons in question are accept/reject and I want to put an AYS on the reject so it isn't used accidentally).
有没有办法让javascript和多个远程提交按钮和平地存在?
Is there a way for javascript and multiple submit buttons in a remote form to exist peacefully?
预先感谢您的帮助...
Thanks in advance for your help...
推荐答案
您尝试使用before
参数吗?它需要一个JavaScript函数,该函数将在远程函数调用之前执行.像这样使用它即可:
Did you try the before
parameter? It takes a JavaScript function, which will be executed before the remote function call. Just use it like this:
<g:submitToRemote value="Reject" update="feedback"
controller="test" action="reject"
before="if (!confirm('sure?')) {return false;}" />
无论您放置在onclick
属性中.这样,您可以轻松地进行验证,获取确认等,甚至可以在提交Ajax调用之前中断onclick处理.有一个类似的after
参数.
Whatever JavaScript you put in the before
parameter will be inserted into the onclick
attribute right before your Ajax updater call. This way you can easily do validation, get confirmations etc. and even break from onclick handling before submitting the Ajax call. There is a similar after
parameter.
这篇关于Grails远程表单,使用javascript进行多次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!