AJAX question... again :-D

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

AJAX question... again :-D

Pietro Maggi
Hi,
Again a question on AJAX.

I'm having some problem, using yahoo library, to have the rendered
response in the "update" div with the <g:formupdate> tag.

What seems strange is that the HTML builted by the Grails taglib
misses any reference to the update operation:

<script type="text/javascript">
function appendMessageRemoteFunction() {
   YAHOO.util.Connect.setForm('appendMessage');
   var callback = {
      success: function(o) { },
      failure: function(o) {
         document.getElementById('errmessage').innerHTML = o.responseText;
      }
   }
   var cObj = YAHOO.util.Connect.asyncRequest('POST',
'/webinar/author/appendMessage',
                                                                     
 callback);
}
</script>


this was built from the code:
<g:formRemote name="appendMessage"
url="[controller:'author',action:'appendMessage']"
update="[update:'updmessage',failure:'errmessage']">

Clearly any reference to the updmessage <div> is missing, so nobody is
going to update it...
Any Idea of what is going on here?

best regards
ciao
Pietro
Reply | Threaded
Open this post in threaded view
|

Re: AJAX question... again :-D

graemer
On 4/20/06, Pietro Maggi <[hidden email]> wrote:

> Hi,
> Again a question on AJAX.
>
> I'm having some problem, using yahoo library, to have the rendered
> response in the "update" div with the <g:formupdate> tag.
>
> What seems strange is that the HTML builted by the Grails taglib
> misses any reference to the update operation:
>
> <script type="text/javascript">
> function appendMessageRemoteFunction() {
>    YAHOO.util.Connect.setForm('appendMessage');
>    var callback = {
>       success: function(o) { },
>       failure: function(o) {
>          document.getElementById('errmessage').innerHTML = o.responseText;
>       }
>    }
>    var cObj = YAHOO.util.Connect.asyncRequest('POST',
> '/webinar/author/appendMessage',
>
>  callback);
> }
> </script>
>
>
> this was built from the code:
> <g:formRemote name="appendMessage"
> url="[controller:'author',action:'appendMessage']"
> update="[update:'updmessage',failure:'errmessage']">

You mistake is that the above should be

<g:formRemote name="appendMessage"
url="[controller:'author',action:'appendMessage']"
update="[success:'updmessage',failure:'errmessage']">


>
> Clearly any reference to the updmessage <div> is missing, so nobody is
> going to update it...
> Any Idea of what is going on here?
>
> best regards
> ciao
> Pietro
>
Reply | Threaded
Open this post in threaded view
|

Re: AJAX question... again :-D

Pietro Maggi
Hi Graeme,
thanks for you reply.

2006/4/20, Graeme Rocher <[hidden email]>:

> On 4/20/06, Pietro Maggi <[hidden email]> wrote:
> > <g:formRemote name="appendMessage"
> > url="[controller:'author',action:'appendMessage']"
> > update="[update:'updmessage',failure:'errmessage']">
>
> You mistake is that the above should be
>
> <g:formRemote name="appendMessage"
> url="[controller:'author',action:'appendMessage']"
> update="[success:'updmessage',failure:'errmessage']">
>

This does not solve my problems (and the documentation on the page
http://docs.codehaus.org/display/GRAILS/Ajax uses the above sintax).
With this I got the HTML:

<script type="text/javascript">
function appendMessageRemoteFunction() {
   YAHOO.util.Connect.setForm('appendMessage');
   var callback = {
      success: function(o) { },
      failure: function(o) {
         document.getElementById('errmessage').innerHTML = o.responseText;
      }
   }
   var cObj = YAHOO.util.Connect.asyncRequest('POST',
'/webinar/author/appendMessage',
                                                                     
 callback);
}
</script>

So my question is still here... how can i get the rendered response on
success (and after this I'll have to figure out how to append this
response to the content of a div).

Ciao
Pietro
Reply | Threaded
Open this post in threaded view
|

Re: AJAX question... again :-D

Pietro Maggi
Hi Graeme,
I got it.

As usual you where right, the syntax to use is:

<g:formRemote name="appendMessage"
url="[controller:'author',action:'appendMessage']"
update="[success:'updmessage',failure:'errmessage']">

but Grails does not generate the right HTML code because there is an
error in the "JavascriptTagLib.groovy" file at line 188:

if(attrs.update.sucess) {

has to be changed to

if(attrs.update.success) {


this solves the problem.

Ciao
Pietro