简体   繁体   中英

Grails formRemote

I have DateFrom and DateTo fields. I want to submit those data to action which will do some business logic but nothing changes on the original GSP, and nothing is updated. How do I manage this? I've tried this:

<g:formRemote name="formName" url="[action: 'myAction']">

Everything is fine but except my action tries to render myAction.jsp.

This is a great place to read how it works.

Basically you need to specify what controller as well:

<g:formRemote name="formName" update="updateMe" url="[controller: 'controller', action:'myAction']">

The "updateMe" is the id of an html-object, preferably div, that you want to alter after submit (but it's not mandatory). It also uses the actionName.gsp to "supply" the answer, this is why you need to have this page create as well.

Remote forms are a bit tricky in the beginning, but they're super simple once you get a hang of it!

This is how I did it:

GSP:

<g:formRemote name="formName" update="updateMe" url="[controller: 'controller', action:'myAction']">
<div id="updateMe">
    <g:render template="updateTemplate"/>
</div>

Action:

...
render template:"updateTemplate"

updateTemlate and updateMe div are both empty.

If you have better solution please tell me.

您可以使用remoteFunction

您需要在表单内编写“提交”按钮,然后触发动作并将一些更改显示到div中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM