Showing posts with label GRAILS AJAX. Show all posts
Showing posts with label GRAILS AJAX. Show all posts

Tuesday, December 23, 2008

g:remotelink and Delete Confirmation

While developing the sample ajax grails application which is available on github, I encountered this problem on g:remoteLink

Everything works good, but if I need to add a delete confirmation on the

<>, the confirmation dialog appears but g:remotelink still goes ahead and compeltes the ajax call even if the user has selected the

<> action="ajaxdelete" id="${contact.id}" before="return confirm('Are you sure?');" update="contactsElement">Delete

Jeff Brown at Spring Source. and his friend Rhyolight, lead developer on GrailsUI, Helped put a wonderful soluction to get around this problem.
Solution is to use Grails UI (Yui plugin), as grailsUI has this wonderful capability to passthrough the config params which grails does not understand it works well.

Here is what the above code was replaced by

&lt gui:dialog
title="Please confirm!"
width="300px"
triggers="[show:[type:'link', text:'Delete', on:'click']]"
controller='contact'
action='ajaxdelete'
update='contactsElement'
params="[id:contact.id]"
form="true"&gtAre you sure you want to delete ${contact.name}?&lt/gui:dialog&gt

Looks like grails UI is very powerful to be ignored.

Wednesday, December 17, 2008

Sample application for AJAX and Grails

I am very impressed with the rapid development Grails Offers, the power of AJAX which grails offers has made it even more powerful. Grails offers many AJAX frameworks which can be added as plugins.

I started with a sample ajax in grails application, which demostrates the following capabilities of grails,
  • g:formRemote : How to use g:formRemote , within and Outside the controller
  • g:formRemote along with g:remoteLink for inline Editing
  • JQuery Validator Plugin : Demostrates JQuery works with conflicts with ScriptAculo and Prototype
  • Grails YUI : Replaced g:remoteLink with grails UI Dialog, for Delete confirmation.
I would like to thank Jeff Brown at Spring Source Inc. and his friend Rhyolight, lead developer on GrailsUI. Without with this demo application would have been incomplete

Please find a link to sample example, which includes all the scenarious of AJAX.

http://github.com/markatharvest/sample-ajax-in-grails/tree/master

Please send me any pull requests, if you guys make some changes