Forum: Ruby on Rails How to pop up a Download Window

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
047c2e2a6349db15db769e3ad46cf936?d=identicon&s=25 Kumar Saurav (sauravsuman012)
on 2009-01-25 13:02

Hi all ,
I have to show window as like you got on click of save(or by pressing of
ctrl+s), which exact function like the crtl+s press.
Please let me know if anyone having any idea regarding this.
It would be great help for me.


Thanks In Advance.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-01-25 17:15
(Received via mailing list)
Kumar Saurav wrote:

> I have to show window as like you got on click of save(or by pressing of
> ctrl+s), which exact function like the crtl+s press.
> Please let me know if anyone having any idea regarding this.
> It would be great help for me.

If your user can hit the Submit button of a form - maybe labeled "Save"
- the
controller's action can call send_file. This returns to the user as the
"Save As
Dialog", which is what you describe.

If your form depends on Ajax, you can add a tiny 1px <iframe> into your
form.
The Save button has this iframe as a _target, and calls a similar action
via
form Submit - not Ajax. The action will render a file with send_file,
and send
it to the <iframe>, which will pop up the Save As dialog. That is how
you can
use Save As without interrupting a page that uses Ajax.
This topic is locked and can not be replied to.