On a dynamic page I have a button ‘downButton’ which is linked to the ‘document’ field in same dataset. I need the button lable to change depending on if the document is empty or has some document uploaded.
Following is the code am using which isn’t working:
$w.onReady(function () {
if ($w("#downButton").link !== null) {
$w('#downButton').label = "Download Judgment";
}
else {
$w('#downButton').label = "Judgment to be uploaded soon";
}
});
Console shows “Wix code SDK Warning: The link parameter that is passed to the link method cannot be set to null or undefined”, twice on each run.
Thanks for using WixCode and for your question. You addressed your question to the “wonderful people”, but I’ll answer instead .
First off, don’t worry about the warning - it is just that, a warning. Since you’ve linked the button to the document field, you are being warned that the field is empty. Of course, you’ve stated that it might be empty, which is what you’re trying to find out. Now, how to find out if the field is empty…
You need to check the document field via the dataset. The following snippet of code shows how to retrieve the field, and how to check if a document exists or not.