Hi there,
I have a data collection with documents inside of it and I am looking to download / open these documents.
I am trying to open the document by using wixLocation but it wont work at all?
How can I open the document with code?
My current code:
import wixLocation from 'wix-location';
import wixData from 'wix-data';
let documents;
$w.onReady(function ()
{
$w('#PageTitle').text = $w('#MainPage').title;
//getting all documents from the collection
wixData.query("Downloads")
.find()
.then((results) => {
//setting the results to the variable declared above
documents = results.items; //see item below
console.log(documents);
})
.catch((err) => {
let errorMsg = err;
});
});
let selectedOption;
export function BtnDownload_click(event, $w)
{
wixLocation.to(documents[selectedOption].doc);
}
export function DownloadsList_change(event)
{
selectedOption = $w('#DownloadsList').selectedIndex;
console.log(selectedOption);
}
Best regards,
Scott Durkin