tags:

views:

595

answers:

3

It seems that with g:formRemote and g:submitToRemote, I can only specify one update target div. What would be a viable strategy for updating multiple divs?

A: 

if you want to stick with using the g:formRemote tags to perform your ajax, it might not be possible. Why not write some jQuery, and roll a custom ajax update? it couldnt be easier!

Chii
+1  A: 

You could instead of using update, use onSuccess and parse the response and update the elements you need to update like this:

<g:formRemote name='loginForm' url="[action:'login']"
    onSuccess='loginOK(e)' >
  <!-- form fields -->
</g:formRemote>
<g:javascript>
  function loginOK( resp ) {
    // parse the resp.responseText and update
  }

</g:javascript>

Or you could just use jQuery and roll your own like the previous answer suggests.

If you want to update one element based on success vs another on failure you can use a map like this:

<g:formRemote name='loginForm' url="[action:'login']" update="[success:'message',failure:'error']">
mbrevoort
A: 

Hi,

there is asolution to this grails problem, you can use taconite, where taconite allows to update muliple elements with one single ajax call

http://malsup.com/jquery/taconite/

and there is another solution posted at someone's blog, but my reputation does only allow me to post one link here on stackoverflow!!!

so i give the title of the blog post "Updating multiple page elements with Grails and Ajax"

Thierry Nicola