Hey everyone. Let me start my saying I’m only just starting my coding journey so be gentle!
I have a client and, as part of the website I’m building, they have a series of interviews (including an intro and a number of Q&As - q1, a1, q2, a2, etc.) with various people they have conducted over the years. I’ve used the content management dataset to store these so they can be displayed on dynamic pages.
The problem is that the interviews are of various lengths; from as few as 2 questions/answers (they ALL have at least 2) right up to 17! As it is, interviews that have fewer questions have huge spaces of emptiness.
I’ve split the page into sections (strips) so what I have been trying to do is hide the strip when the relevant q field is empty (obviously if the ‘q’ field is empty, so is the ‘a’ field) to limit the length of the page.
Every row has q1/a1 and q2/a2 but then they vary in numbers. I’ve written the following code which I thought would help hide the strip if the field in question is blank. This is then repeated from columnStrip3 for Q3, columnStrip4 for Q4, etc. up to the maximum of 17.
$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
let Spotlight = $w("#dynamicDataset").getCurrentItem();
if(//#dynamicDataset.q3===null){
$w("#columnStrip3").hide();
$w("#columnStrip3").collapse();
} else {
$w("#columnStrip3").show();
$w("#columnStrip3").expand();
}
It shows no errors, but also doesn’t do what I expect. In fact, it does nothing at all. Any help would be appreciated.
Thanks in advance.
Gary