gtaranti:
So, I’m using a mini-form (with ‘GET’ method) in each row in order to utilise the phx-trigger-action binding and submit the auction_id to the controller, in order for the action to prepare the pdf and send it to the user as a download…
Is my approach of preparing the PDFs and sending to the user entirely wrong?
Hmm, have you tried using buttons with a phx-click
binding and a phx-value
set to auction_id
and then prepare the pdf in the LiveView’s handle_event
callback?
Also, this forum post seems relevant to your use case:
Welcome to the forum @GeorgeMiller !
is there a reason why you couldn’t trigger the download with an ordinary link to a file in the priv/static folder?
When your file is created (let’s call it data.csv), copy it to priv/static/. You can get the location of the priv folder using :code.priv_dir(:your_app_name).
Create a download link in your view:
<%= link "Download", to: Routes.static_path(@socket, "data.csv"), target: "_blank" %>
(You will have to add the csv extension to the list of…
1 Like