Collapsing text item when content manager text field is empty

Good day ! I am not a coding champion AT ALL and I have tried searching for answers but nothing seems to work, please help !!
My dataset doesn’t seem to be “good” in the code, but I can’t figure out why ?


This is the name of my dataset


This is what I get as a result, but can’t figure out why.

Thank you so much for your help

The shown picture do not show a dataset. It shows a “DATA-COLLECTION”.
You will have to connect your DATA-COLLECTION with a DATASET first.


“CVFR” —> DATA-COLLECTION (DATABASE)
“dataset1” —> this one could be a possible —> DATASET-ID

Your shown CODE is made for a DATASET and NOT for a DATA-COLLECTION.

Wix-DATA —> DATA-COLLECTION (DATABASE)
https://www.wix.com/velo/reference/wix-data

Wix DATASET —> DATASET
https://www.wix.com/velo/reference/wix-dataset

Thank you so much, I hadn’t thought of that !! I will try it and see if it works.

It is working, thank you. If I have more than one textbox to do, do I have to repeat the same code with every textbox name or is there a way I can do it all together ?

@hurtubisecarl
Repeat or perhaps do it with the help of a loop…

for (var i = 0; i < array.length; i++) {
 
}

@russian-dima Thank you very much !! Did a repeat and it worked perfectly.

@russian-dima OH LORD… I must have messed up something, it is not working anymore…

@hurtubisecarl :joy::rofl: What’s the problem ?
What is not working? What did you do/changed?
Where is your current code?

You know → NO-INPUT = NO-OUTPUT

1 Like

@russian-dima OK, I am trying to understand the logic.
I have many text items to identify as “collapsed” if there is no text in the dataset.
Is there a pattern that needs to be respected (example: the first text boxes need to be coded first), or any pattern will do ?
This is what I need to collapse.

Whenever I put my code in, the first ones disappear even if there is text inside the cell (dataset). I took out everything in my coding in order to start again. But now, even if I try to put the code back in (in order of appearance), it still doesn’t work.

@hurtubisecarl
I need to see your current working CODE! (in a CODE-TAG please - NO PIC!)

@russian-dima

$w.onReady( function () {

$w( '#dynamicDataset' ).onReady(() => {    

const item = $w( ‘#dynamicDataset’ ).getCurrentItem();

if (!item.altDesc1) {

        $w( '#text95' ).collapse(); 

 }  **else**  { 
  $w( '#text95' ).expand(); 
    } 
}); 

});

@hurtubisecarl

$w.onReady(function () {
   $w('#dynamicDataset').onReady(() => {   
      const item = $w('#dynamicDataset').getCurrentItem();
      console.log("ITEM: ", item)
      console.log("ITEM-altDesc1: ", item.altDesc1)

      if (!item.altDesc1) {$w('#text95').collapse();}
      else {$w('#text95').expand();}
    });
});

Check which results you get in the CONSOLE.

-Do you get any error-message?
-Did you perhaps “hide” your text before and did not “show” it back again?

 if (!item.altDesc1) {$w('#text95').collapse(), $w('#text95').show();}
      else {$w('#text95').expand(), $w('#text95').hide();}

-Dynamic-Dataset is connected?

@russian-dima This is what I get in the console

Nothing is hidden on the page.

This is code for only one TEXT BOX.

@hurtubisecarl
Do you have any “global-variables” in your code? (else-where)?

@russian-dima So sorry, I have no idea what that would mean…

@hurtubisecarl
Sorry, can’t help here without taking a look into the project.
You can contact me via mail, if you need more help.
Info about me in my profile.:wink:

@russian-dima OH !!! I was able to make it all work out exactly how I wanted to, with repeaters and some more searching. Thank you very much for your time, I appreciate it a lot.

1 Like