rails re-enable button_to after downloading file

397 views Asked by At

I'm using button_to in a page for downloading a PDF file.

= button_to "Download Report", evaluation_report_attempt_path, method: :get, class: "btn btn-primary", data: { disable_with: "Downloading..."}

There is no page redirection happening here. After the file is downloaded, the button remains disabled. How do I re-enable the button after the function is completed?

1

There are 1 answers

0
lg86 On

Yo can try these

$(window).unload(function() {
  $.rails.enableFormElements($($.rails.formSubmitSelector));
});