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. I have read your blog its very attractive and impressive. I like it your blog.

    Java Online Training Java EE Online Training Java EE Online Training Java 8 online training Core Java 8 online training

    Java Online Training from India Java Online Training from India Core Java Training Online Core Java Training Online Java Training InstitutesJava Training Institutes

    ReplyDelete