Showing posts with label remoteFunction. Show all posts
Showing posts with label remoteFunction. Show all posts

Wednesday, June 16, 2010

grails-ui menubar and ajax with remoteFunction

I wanted to turn the links of the grails-ui menubar into ajax remoteFunctions or remoteLinks. This was - once more - far more complicated than I had anticipated. Fortunately almighty google brought me to the solution. The ugly thing: One has to change the code like stated in the jira. Now another ugly thing about the solution is - as indicated by the author - that one still has to provide a url. Not a problem I thought, but the whole thing did not work at all. I had to spend some time, before I could figure out what was going on:

Both - the URL and the remoteFunction - are executed. The remote function comes first (which is a good thing as we will see), but then the URL kicks in and you have a double page change behaviour. The fix is as easy as you can imagine (I wish someone had told me). You have to add 'return false' at the end of the remote function. This stops the URL href feature from being executed at all. VoilĂ  remote function can reign in peace now.

Tuesday, May 4, 2010

passing javascript parameters with remoteFunction

There have been a lot of examples where I needed to pass javascript variables through a remoteFunction in order to Ajax-Update a part of my web application.

I had almost given up when I found the solution in a blog entry. I wasn't able to guess the correct escaping of ' signs on my own, but this solution obviously got it right:

${remoteFunction(controller:'myController',
action:'someAction',update:'targetDiv',
params:'\'oneParameter=\'+jsOneParameter+\'&anotherParameter=\'+jsSecondParameter')};