I can't figure out how to "catch" the event (if it exists) when my Rails app is done sending a file with the send_data
method:
# view
= link_to 'Download!', download_path
# controller
def download
# some logic
send_data csv_data, filename: 'export.csv'
end
I would like to catch the event when my server is done sending the CSV file to the client in order to hide a loading.gif image which is shown right when you click on the download link (there is nothing related to AJAX here, to be clear).
Any help would be appreciated, thanks!
(Ruby 1.9.3, Rails 3.2.13)
Similar question (using cookie): Browser event when downloaded file is saved to disk
update:
I tried to listen on the events of my link, but no event at all is shown:
monitorEvents(document.body.querySelectorAll('a#export_link'));