Hello, I would like to add a confirmation to a file download. The problem I'm seeing is that my page does not refresh after the file download, so that any confirmation dialog is not cleared. Ideally I'd use an ajax callback to trigger the file download; the callback code does get triggered, but the file is not downloaded. I figure I'm missing something obvious. File download is using...
self requestContext respond: [:response | response contentType: ... ] ...so I understand why the rendered dialog does not refresh, given that the response is not the page content. Using an ajax callback... onClick: ( (html jQuery ajax callback: [self downloadMethod]) ... ) ...does not do the download, even though the download method is triggered. That also
makes sense, since the requestContext is the ajax callback, not the page get. If that did work, I could use the javascript confirm. So, what this trick? ... I hate not seeing what should be a simple solution :-) Thanks for any help, Bob Nemec _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Bob Nemec
|
Hi Bob,
I don't think you can do a file download using an ajax request. You will need to do it like this: onClick: ( (html javascript callback: [self downloadMethod]) ) You can probably insert the use of a confirmation dialog in the script above (untested): onClick: ( (html javascript callback: [self downloadMethod]) confirm: 'Do you want to download?') There also exist jQuery plugins [1] to get close to an ajax-like behavior for file downloads. cheers Johan [1] http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/ On 25 Apr 2014, at 16:21, [hidden email] wrote: > Hello, > I would like to add a confirmation to a file download. The problem I'm seeing is that my page does not refresh after the file download, so that any confirmation dialog is not cleared. Ideally I'd use an ajax callback to trigger the file download; the callback code does get triggered, but the file is not downloaded. I figure I'm missing something obvious. > > File download is using... > > > self requestContext respond: [:response | response contentType: ... ] > ...so I understand why the rendered dialog does not refresh, given that the response is not the page content. > > Using an ajax callback... > onClick: ( (html jQuery ajax callback: [self downloadMethod]) ... ) > ...does not do the download, even though the download method is triggered. > That also makes sense, since the requestContext is the ajax callback, not the page get. > If that did work, I could use the javascript confirm. > > So, what this trick? ... I hate not seeing what should be a simple solution :-) > > Thanks for any help, > Bob Nemec > _______________________________________________ > seaside mailing list > [hidden email] > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |