Also you the opposite of collapse() is exapnd() not show().
So if you use collapse() in case1, you have to use expand() in case2.
if you use hide() on case1, only then you can use show() in case2.
@emilkrarup please don’t refer me to other long threads. Just explain to me in your own words, what it means. Do you have a “button1” field in you collection? or what?
@jonatandor35
The #button1 is set to: click action connects to field “Datablad” in the dataset called “Referencer-erhverv dataset”. The field Datablad contains PDF-documents.
The #text18 is to connect to field “Faktaboks” in the dataset called “Referencer-erhverv dataset”- The field “Faktaboks” contains rich text.
if (!item.button1) if (!item.text18) { checks to see if the item variable from the previous line includes the document/text field, which is the field in the collection that stores the document/text.
@emilkrarup I don’t think I understood your explanation.
But I know to read code, and I know that if (!item.button1) means: if a collection field of field key “button1” is not true, then…
and if (!item.text18) means that if (!item.text18) means: if a collection field of field key “text18” is not true, then…
@emilkrarup let me know what exactly you’d like to happen:
Do you want to collapse the elements if the fields datablad and faktablad are both not true?
@jonatandor35 Thank you for your patience - I am new to this. I want to collapse the elements separately. I want button1 to collapse if datablad is not true. The same with text18 when faktablad is not true, but I want the elements to collapse separately.
@emilkrarup Now I got you, so first, remove this code:
//Keep the begging of the code as is
//THIS CODE SHOULD BE DELETED:
if (!item.button1) if (!item.text18) {
$w("#button1").collapse(); $w("#text18").collapse();
}
else
{
console.log("Expand");
$w("#button1").show(); $w("#text18").show();
}
//keep the rest of the code
And instead of this chunk of code, use the following code (in the same rows):