In a GSP (Groovy Server Page), I’m using <g:submitToRemote update="..."> to update a <div> after the server-side call.
According to the tag’s documentation and other sources on the web, the target <div> can be placed arbitrarily at the page. In my testings, however, I find that the <div> needs to surround the <g:submitToRemote> tag.
If it does not, the <div> will be updated with some “random” contents (i.e., parts of the form that surround the <g:submitToRemote> tag).
Consider the following GSP code:
<html>
<head>
<g:javascript library="prototype" />
</head>
<body>
<div id="updateMe_NOT_WORKING">${message}</div>
<g:form>
<div id="updateMe_WORKING">
<g:submitToRemote value="Click Me"
action="someAction" update="updateMe_NOT_WORKING" />
</div>
</g:form>
</body>
</html>
That’s on Grails 1.3.4.
What am I missing? – Thanks
According to my testings,
g:submitToRemote‘sactionattribute must not point to the current controller’s current action (as this will insert/duplicate the current view into the current view).It works if you specify an alternate action in
g:submitToRemote– i.e.,If this action provides a model – i.e.,
then there needs to be a corresponding GSP – that, in this case, should state,
Alternatively, the action can use the
rendermethod – like this,I’ll leave this issue open for some time, in case there might be additional responses, and, if there aren’t, will accept this answer as the solution.
Thanks