Hi, I’m new at coding, so please excuse me if this is a silly question or if what I’m asking isn’t possible.
I set up my page as Code Queen Nayeli did. Thank you - it all works fine! The idea is that the member fills out a form and submits it, then on their ‘submission history’ page it updates with a summary of what the client has submitted. This works fine and updates only what the logged-in member has submitted.
Now I am struggling with the buttons because I’m using a repeater on the member’s page. I’ve liked a ‘Download Estimate’ button on the repeater to the dataset I’m using, and the document downloads fine. But now I would like the download button to show only when a document is available in the database. I’ve tried the code offered here but it doesn’t work. I’ve looked at working with repeaters and I’m confused. Do I have to use $item? Or is what I’m after not possible?
Thanks for watching my videos. So I think you want to hide download button on a repeater if the field is empty (no document)? If yes, try something like this:
My code has a lot going on but it should give you a hint to what you should write in your code …
(In my code popupButton opens a lightbox … and soloPageButton is disabled if no word is found in the database, preventing them from clicking.)
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
$w('#repeater2').onItemReady(($item , itemData , i ) => {
let itemEmpty = $item('#companyDataset').getCurrentItem();
let soloEmpty = itemEmpty.soloPage;
$item('#popupButton').onClick(() => {
let item = $item('#companyDataset').getCurrentItem();
wixWindow.openLightbox('Popup', item)
});
});
$w("#repeater2").onItemReady( ($w, itemData, index) => {
let word = itemData.soloPage;
if ( word === undefined) {
$w("#soloPageButton").disable();
} else if ( word !== undefined) {
$w("#soloPageButton").enable();
}
});
});