Home Rails axlsx and ajax
Reply: 0

Rails axlsx and ajax

user1134
1#
user1134 Published in June 23, 2018, 11:30 pm

I am trying to generate an excel file to open once the browser has downloaded it. I am using axlsx and I can generate the file fine.

However what I want to do from there is set it up so when I click my link that fires my controller to download my excel file have it show a spinner icon and when the download is complete and excel opening have the spinner icon go away.

I know how to do the javascript to show and hide, I know how to generate the excel file on the rails side. I'm having trouble the two to work together.

Doing a format.js and trying to do ajax that way (using render file) doesnt seem to fire the file javascript in that file, but the Excel opens fine. (I would like to use that file to do the hide of the icon)

The closest thing I have figured out is doing a .on('ajax:complete, function(){ window.open(path to my excel file) code to hide my icon})

And that will open a new tab and then open the downloaded excel file and close the tab.

I'd like to do that without opening a new tab (and preferably without an iframe)

Is this not possible?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310709 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO