Skip to content

Commit

Permalink
MDL-74153 portfolio_download: fix download form
Browse files Browse the repository at this point in the history
The download form usas autosubmit to start downloading the content. This
breaks the JS modules loading because the page loading is cancelled when
the form is submitted. To prevent this from happen the download form now
has a hidden iframe to execute the download action without affecting the
rest of the page.
  • Loading branch information
ferranrecio committed Mar 16, 2022
1 parent 967d9b2 commit e9de12e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions portfolio/download/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
// if they don't have javascript, they can submit the form here to get the file.
// if they do, it does it nicely for them.
echo '<div id="redirect">
<form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
<form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform" target="download-iframe">
<input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
</form></div>
</form>
<iframe class="d-none" name="download-iframe" src=""></iframe>
</div>
';

$PAGE->requires->js_amd_inline("
Expand All @@ -41,5 +43,3 @@
}).submit();
});");
echo $OUTPUT->footer();


0 comments on commit e9de12e

Please sign in to comment.