File Download not working

Hi All
Version 7.18 beta
I'm developing a Nodejs system which has a requirement to produce a lot of PDFs. The PDFs are stored in a folder outside the public folders. I have a repeat table which shows all the pdfs. When I click on a button I want the user to be able to view the pdf. I am using a file download server action.


This triggerd from the button, in the repeat table. When I click the button nothing happens , a quick look on Dev tools I can see the action is completing

Only when I click on the blue initiator (DMXAppConnect) does it then download and display in another window. It feels like I'm not triggering correctlyany ideas?

Thanks

In order to download the file, you need to call the path/url of your server action using a href= and not call the server action via dynamic event in button click.

  1. Set up a new route in Wappler route manager, pointing to your download server action,
  2. On your webpage, style the anchor tag like a button,
a.download-button {
  display: inline-block; /* Allows setting width and height */
  padding: 10px 20px; /* Adjust padding as needed */
  background-color: #007bff; /* Example background color (blue) */
  color: white; /* Text color */
  text-decoration: none; /* Remove underline */
  border: none; /* Remove default border */
  border-radius: 5px; /* Rounded corners */
  cursor: pointer; /* Change cursor to pointer on hover */
  font-size: 16px; /* Adjust font size */
  font-weight: bold; /* Make the text bold */
  transition: background-color 0.3s ease; /* Smooth transition on hover */
}

a.download-button:hover {
  background-color: #0056b3; /* Darker background on hover */
}

a.download-button:active {
  background-color: #004085; /* Even darker background on click */
}
  1. Point the href to your new download server route,
  2. Add target="_blank" inside your anchor tag. This will keep your existing window open and most browsers will automatically close the new window when the download is finished,
  3. Add download="" inside your anchor tag as this also helps with some browser behaviors

Thanks , I will give that a try tonight