Mithesh M
Mithesh M

Reputation: 21

rails re-enable button_to after downloading file

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?

Upvotes: 2

Views: 401

Answers (1)

lg86
lg86

Reputation: 375

Yo can try these

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

Upvotes: 0

Related Questions