...">

Grails / AJAX: updating an arbitrary region on a page using g: submitToRemote

In GSP (Groovy Server Page) I use <g:submitToRemote update="...">to update <div>after a server side call.

According to the tag documentation and other sources on the Internet, the target <div>can be placed arbitrarily on the page. However, in my tests, I found that I <div>should surround the tag <g:submitToRemote>.

If this is not the case, it <div>will be updated with some “random” content (ie the parts of the form that surround the tag <g:submitToRemote>).

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>

What's on Grails 1.3.4.
What am I missing? - Thank

+3
2

g:submitToRemote action ( / ).

, g:submitToRemote - i.e.,

<g:submitToRemote value="Click Me"
    action="ajaxAction" update="updateMe" />

- ,

def ajaxAction = { [message: 'foo'] }

GSP - ,

$message

, render - ,

def ajaxAction = { render 'foo' }

, , , .

+4

, , . = "..." g: submitToRemote. , , g:.

, <div> .

+3

Source: https://habr.com/ru/post/1771169/


All Articles