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.

1 comment:

  1. Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks Technical Action Group Managed IT Service

    ReplyDelete