Hello all,
I have a repeater that shows if students have submitted an assignments and allows teachers to download, grade and return these assignments.
In my repeater I’ve added buttons to allow these assignments to be downloaded by the teachers but I can’t for the life of me figure out how to get these documents to download.
I’ve tried simply setting the value of the button to match the relevant field in the database which didn’t work.
I’ve tried creating an onClick action to navigate to the document but the value stored in the database isn’t a usable URL according to the errors and console logs I get.
I even tried using .split to break-up the database value so I can get just the portion I want but event that doesn’t work as I get an error stating that .split isn’t a function that can be used in the repeater.
I’d be happy to post some code if it will help, just not sure which failed code to post.
Thanks in advance.
Yisrael has done a tutorial about using inputs with repeaters, maybe it can help you out here or at least give you a helping hand to fix your problem.
https://www.wix.com/corvid/forum/corvid-tips-and-updates/example-input-repeaters
Thanks but my particular problem is with setting a file for download dynamically. I don’t need to worry about user input so this example, while very informative, doesn’t help me much with this.
I saw the Code Queen tutorial about setting downloads but she’s using datasets and I’m doing everything I can to avoid datasets and instead work directly with the databases (had some issues with the datasets).
Thanks again for the quick response.
I got it to work!!!
It took some finagling but here’s the code that ended up working:
if (itemData.abstractSubmitted === true ) {
absource = itemData.abstract;
let absourceJSON = JSON.stringify(absource);
console.log(absourceJSON);
let name = absourceJSON.split(“/”)[4];
console.log(name);
let url = absourceJSON.split(“/”)[3];
console.log(url);
console.log(“Student abstract is available at:”);
console.log(absourceJSON);
$w(‘#iconButton1’).onClick( (event) => {
wixLocation.to(“https://docs.wixstatic.com/ugd/“+url+”?dn=”+name);
})
}
I just had to realize that the value for the field was an object. Once I did then I was able to turn it into a string and move on from there.
I used some of Code Queen’s tutorial for getting the file to download without redirecting.
Thanks again for the help @givemeawhisky .