Hi all,
Pardon the complicated title. Here's my situation: I'm working on a Grails app, and using jQuery for some of the more complex UI stuff.
The way the system is set up, I have an item, which can have various files (user-supplied) associated with it. On my Item/show view, there is a link to add a file. This link pops up a jQuery modal dialog, which displays my file upload form (a remote .gsp).
So, the user selects the file and enters a comment, and when the form is submitted, the dialog gets closed, and the list of files on the Item/show view is refreshed. I was initially accomplishing this by adding
onclick="javascript:window.parent.$('#myDialog').dialog('close');"
to my submit button.
This worked fine, but when submitting some larger files, I end up with a race condition where the dialog closes and the file list is refreshed before the new file is saved, and so the list of files is out of date (the file still gets saved properly).
So my question is, what is the best way to ensure that the dialog is not closed until after the form submit operation completes? I've tried using the
<g:formRemote tag in Grails, and closing the dialog in the "after" attribute (according to the Grails docs, the script is called after form submission), but I receive an error (taken from FireBug) stating that
window.parent.$('#myDialog').dialog is not a function
Is this a simple JavaScript/Grails syntax issue that I'm missing here, or am I going about this entirely wrong?
Thanks so much for your time and assistance!