1

我正在使用表单远程提交表单。如果成功保存数据意味着我想更新列表 div。如果失败意味着我想刷新错误 div。formRemote Of grails 中是否有任何选项?

4

2 回答 2

1

是的,formRemoteonFailure,onSuccessonComplete.

<g:formRemote name="saveData" url="[controller: 'book', action: 'byAuthor']" onComplete="jQuery('#completeDivId').html(data)" onSuccess="jQuery('#successDivId').html(data)" onFailure="jQuery('#failureDivId').html(data)">
    ...
</g:formRemote>
于 2013-08-13T08:03:21.463 回答
0

如果这些 div 不同,则必须使用 javascript 事件,在这种情况下,将 onSuccess 和 onFailure 参数添加到表单中:

<g:formRemote name="myForm" onSuccess="successFunction" onFailure="failureFunction" url="...">
</g:formRemote>

如果 div 相同,您可以使用 formRemote 标签的 update 参数设置 div 的 id:

<g:formRemote name="myForm" update="updateMe" url="...">
</g:formRemote>
<div id="updateMe">this div is updated with the result of the byAuthor call</div>

有关更多示例,请参阅grails formRemote 文档

于 2013-08-13T08:03:35.270 回答